尝试在localhost上运行asp.net核心应用程序时出现错误404

时间:2019-07-20 05:13:30

标签: c# asp.net-core iis

我有一个基于asp.net core 2.0的应用程序。当我尝试在Visual Studio 2017中将其作为项目运行时,一切正常,但是当我发布并尝试通过命令提示符或IIS托管运行它时-该程序有效,甚至提供了一些日志,但网站无法正常工作当我尝试访问它时,出现404错误。可能是什么问题?

这是我在命令提示符下得到的输出:

E:\ Projects \ DotNet \ PublishTEST> dotnet。\ RSSAggr

托管环境:生产

内容根路径:E:\ Projects \ DotNet \ PublishTEST

现在收听:http://localhost:5000

应用程序已启动。按Ctrl + C关闭。

Program.cs

public class Program
{
        public static void Main(string[] args)
        {
            var host = BuildWebHost(args);

            using (var scope = host.Services.CreateScope())
            using (var context = scope.ServiceProvider.GetService<AppDbContext>())
            {
                context.Database.EnsureCreated();
            }

            host.Run();
        }

        public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
                .Build();
}

appsettins.json

{
  "Logging": {
    "IncludeScopes": false,
    "Debug": {
      "LogLevel": {
        "Default": "Warning"
      }
    },
    "Console": {
      "LogLevel": {
        "Default": "Warning"
      }
    }
  }
}

web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\RSSAggregator.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
    </system.webServer>
  </location>
</configuration>

0 个答案:

没有答案