Cannot get ASP.NET Core Web API for working with IIS

I am creating an ASP.NET Core MVC Web Api application and I am trying to get it to work with IIS on my own machine. I read different blogs and tried different things, but just can't get it to work ... My Winform client gets 404 when I call the Web api. Navigating the site using a web browser gives me error HTTP 403.14 - Forbidden.

Im works under Windows 10 Pro. IIS Installed hosting package for the main ASP.NET server

I added the site to IIS. The application pool is installed in No Managed Code. In VS2015 Publish the website in a local folder. I copy the contents of this folder to the folder of my website where IIS runs. Then I expect this to work, but it is not: (

Here is my setup:

web.config

<system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /> </handlers> <directoryBrowse enabled="true"/> <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\aspnetcore-stdout" forwardWindowsAuthToken="false" /> 

Program.cs

 public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseWebRoot("wwwroot") .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .Build(); host.Run(); } 

StartUp.cs

  public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); Configuration = builder.Build(); } 

appsettings.json

 { "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Debug", "System": "Information", "Microsoft": "Information" } } } 

project.json:

  { "dependencies": { "Business": "1.0.0-*", "Data": "1.0.0-*", "Microsoft.AspNetCore.Mvc": "1.1.0", "Microsoft.AspNetCore.Routing": "1.1.0", "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0", "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final", "Microsoft.AspNetCore.Server.Kestrel": "1.1.0", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0", "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0", "Microsoft.Extensions.Configuration.Json": "1.1.0", "Microsoft.Extensions.Logging": "1.1.0", "Microsoft.Extensions.Logging.Console": "1.1.0", "Microsoft.Extensions.Logging.Debug": "1.1.0", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0", "Microsoft.NETCore.App": "1.1.0" }, "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final" }, "frameworks": { "netcoreapp1.0": { "imports": [ "dotnet5.6", "portable-net45+win8" ] } }, "buildOptions": { "emitEntryPoint": true, "preserveCompilationContext": true }, "runtimeOptions": { "configProperties": { "System.GC.Server": true } }, "publishOptions": { "include": [ "wwwroot", "**/*.cshtml", "appsettings.json", "web.config" ] }, "runtimes": { "win10-x64": {} }, "scripts": { "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] } } 

Website in IIS

enter image description here

Application Pool in IIS

enter image description here

Folder structure for website enter image description here

My iis

enter image description here

+5
source share
1 answer

IIS point to MyWebAPI instead of MyWebAPI/wwwroot . Otherwise, you will receive the error message "HTTP Error 403.14 - Forbidden".

Here is a demo application on GitHub . It uses the same setting as the application in your answer. It worked when I published it in my IIS as follows:

 dotnet publish -o C:\inetpub\wwwroot\sandbox\ 
+2
source

Source: https://habr.com/ru/post/1263151/


All Articles