【发布时间】:2017-12-19 14:38:36
【问题描述】:
我试图在 IIS 上运行我的 .NET Core 2.0 应用程序,但我总是收到 网页找不到 404 异常。
当我转到事件查看器时,我收到以下消息:
Application 'MACHINE/WEBROOT/APPHOST/SPADWATCH' started process '516' successfully and is listening on port '18579'.
这是我所做的设置:
我尽可能遵循以下指南:Guide。
首先,我安装了 .NET Core 运行时(您可以在模块页面中看到)。
我还调整了应用程序池:
这是我的 program.cs 文件中的代码:
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
我的启动.cs
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvc();
}
}
以及自动生成的 web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\TestWebApplication1.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
<!--ProjectGuid: 5a95b46e-f37a-4205-b510-9fdc76cdddfa-->
我是不是忘记了什么?
【问题讨论】:
-
试试你的机会,将
.UseIISIntegration()添加到您的BuildWebHost。这可能会有所帮助。 -
@S.Akbari 我可以添加它,但我之前尝试过它并没有改变任何东西。
-
我认为这是 ASP.NET Core 1.0 所必需的
标签: c# asp.net .net iis asp.net-core