【问题标题】:Run .NET Core 2.0 on IIS giving 404在 IIS 上运行 .NET Core 2.0 给出 404
【发布时间】: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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-27
    • 1970-01-01
    • 2021-09-25
    • 2018-10-13
    • 1970-01-01
    • 1970-01-01
    • 2018-10-20
    相关资源
    最近更新 更多