我正在构建一个ASP.NET核心MVC Web Api应用程序,我正试图让它在我自己的机器上使用IIS.我已经阅读了不同的博客并尝试了不同的东西,但似乎无法让它工作......我的Winform客户端在调用Web API时只获得404.通过网络浏览器导航到网站roo给我一个HTTP错误403.14 - 禁止.
我正在运行Windows 10 Pro.IIS已安装.已安装ASP.NET Core Server Hosting Bundle
我在IIS中添加了该网站.应用程序池设置为"无管理代码".在VS2015中,我将网站发布到本地文件夹.我将该文件夹的内容复制到IIS正在查找的网站文件夹中.然后我会期望它工作,但它没有:(
这是我的设置:
web.config中
Program.cs中
public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseWebRoot("wwwroot") .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() .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%" ] } }
IIS中的网站
IIS中的应用程序池
网站路径的文件夹结构
我的IIS