gpt4 book ai didi

c# - 在给出 404 的 IIS 上运行 .NET Core 2.0

转载 作者:行者123 更新时间:2023-11-30 18:15:34 27 4
gpt4 key购买 nike

我正在尝试在 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-->

我是不是忘记了什么?

最佳答案

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

关于c# - 在给出 404 的 IIS 上运行 .NET Core 2.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47889300/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com