Невозможно разместить таргетинг на ядро ​​Web Api 2.1. Net framework 4.7.2 для IIS - PullRequest
0 голосов
/ 17 апреля 2020

У меня действительно базовый c Web Api, который был взят из шаблона. Net Core 2.1, предназначенного для. Net framework 4.7.2 Он выполняется через IIS Express и профиль проекта как хорошо, но при использовании IIS в качестве профиля, он просто останавливается в режиме отладки при отладке и при запуске через IIS, просматривают сайт, выдает 404. Ниже показано, как Program.cs и startup.cs идут

public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
         WebHost.CreateDefaultBuilder(args)            
        .UseKestrel()
        .UseContentRoot(Directory.GetCurrentDirectory())
        .UseIISIntegration()
        .ConfigureAppConfiguration((hostingContext, config) =>
        {
            var env = hostingContext.HostingEnvironment;
            var networkEnvironmentBasePath = string.Empty;
            switch (env.EnvironmentName)
            {
                case "Development":
                    networkEnvironmentBasePath = "\\\\chaays.amprog.com\\devinet\\Configuration\\";
                    break;
                case "Local":
                    networkEnvironmentBasePath = "C:\\charon.cmiprog.com\\DevInet\\Configuration\\";
                    break;
                case "Test":
                    networkEnvironmentBasePath = "\\\\nays.amprog.com\\testinet\\Configuration\\";
                    break;
                case "UAT":
                    networkEnvironmentBasePath = "\\\\ays.connect-link.com\\UATInet\\Configuration\\";
                    break;
            }

            config.AddJsonFile("appsettings.json", true, true)
            .AddJsonFile("appsettings.Development.json", true, true)
                // .AddJsonFile($"appsettings.{env.EnvironmentName}.json", true, true)
                .AddJsonFile("appsettings.local.json", true, true)
                //.AddJsonFile(networkEnvironmentBasePath + "ApiEndpoints.json", true, true)
                .AddJsonFile("ApiEndpoints.local.json", true, true);
                //.AddJsonFile(networkEnvironmentBasePath + "Kafka.json", false, true);
            config.AddEnvironmentVariables();
        })
        .ConfigureLogging((hostingContext, logging) =>
        {
          logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
          logging.AddConsole();
          logging.AddDebug();
        })
        .UseStartup<Startup>();

Startup.cs

public void ConfigureServices(IServiceCollection services)
{
 services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
 //some authentication and swagger code goes here
}

В методе настройки,

public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApiVersionDescriptionProvider provider)
{
 app.UseAuthentication();
 app.UseMvc();
 app.UseSwagger();
 app.UseSwaggerUI(
         options =>
            {
                // build a swagger endpoint for each discovered API version
                foreach (var description in provider.ApiVersionDescriptions.OrderByDescending(x => x.ApiVersion).ToList())
                {
                    var name = description.GroupName.ToUpperInvariant();
                    if (description.IsDeprecated)
                    {
                        name += " (deprecated)";
                    }
                    options.SwaggerEndpoint($"{description.GroupName}/swagger.json", name);
                }
            });

Мой web.config имеет вид

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <location path="." inheritInChildApplications="false">
 <system.webServer>      
  <handlers>
    <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
  </handlers>
  <aspNetCore processPath="bin\IISSupport\VSIISExeLauncher.exe" arguments="-argFile IISExeLauncherArgs.txt" stdoutLogEnabled="false">
    <environmentVariables />
  </aspNetCore>
</system.webServer>
</location>
<system.web>
<authentication mode="Windows" />
</system.web>
</configuration>

У меня есть параметры запуска. json как

{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iis": {
  "applicationUrl": "http://localhost/AcordRequestProcessingApi",
  "sslPort": 0
},
"iisExpress": {
  "applicationUrl": "http://localhost:53886",
  "sslPort": 0
}
},
"profiles": {
"IIS Express": {
  "commandName": "IISExpress",
  "launchBrowser": true,
  "launchUrl": "api/Values",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
  }
},
"AcordRequestProcessingApi": {
  "commandName": "Project",
  "launchBrowser": true,
  "launchUrl": "swagger",
  "applicationUrl": "https://localhost:5001;http://localhost:5000",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
  }
},
"IIS": {
  "commandName": "IIS",
  "launchUrl": "swagger",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
  }
}
}
}

Редактировать:

К вашему сведению, я вижу это в информации о stdout:

Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
  User profile not available. Using 
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\4.0.30319.0\AutoGenKeys\S-1-5- 
82-3006700770-424185619-1745488364-794895919-4004696415\DataProtection' as 
key repository and Windows DPAPI to encrypt keys at rest.
Hosting environment: Development
Content root path: E:\Ays\Ticket TrackBy\AcordRequestProcessingApi\solAcordRequestProcessingApi\AcordRequestProcessingApi
Now listening on: http://127.0.0.1:26695
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost/AcordRequestProcessingApi  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 POST 
http://127.0.0.1:26695/ACORDREQUESTPROCESSINGAPI/iisintegration  0
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 157.718ms 202 
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 401.6889ms 404 
Application is shutting down...
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...