在IIS上运行.NET Core 2.0,提供404

时间:2017-12-19 14:38:37

标签: c# asp.net .net iis asp.net-core

我正在尝试在IIS上运行我的.NET Core 2.0应用程序但我总是得到一个网页无法找到404例外

当我转到事件查看器时,我收到以下消息:

Application 'MACHINE/WEBROOT/APPHOST/SPADWATCH' started process '516' successfully and is listening on port '18579'.

这是我做的设置:

我尽可能地遵循以下指南:Guide。 首先我安装了.NET Core运行时(正如您在模块页面中看到的那样) Modules

我还调整了应用程序池:

Pool

这是我在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();
}

我的startup.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-->

我忘记了什么吗?

1 个答案:

答案 0 :(得分:0)

这是我的一个愚蠢的错误,显然我使用了错误的网址。但我在这里发布的配置有效!