index.html未显示为默认页面

时间:2016-03-03 16:25:37

标签: c# asp.net-core

我在.NET Core中创建了一个 Web应用程序,在wwwroot我有 index.html ,它没有作为默认页面加载,它只有当我明确地调用它时才会加载。

这是我的project.json

{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel"
  },

  "frameworks": {
    "dnxcore50": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ]
}

这是我的创业公司:

public class Startup
{
    // This method gets called by the runtime. Use this method to add services to the container.
    // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
    public void ConfigureServices(IServiceCollection services)
    {
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app)
    {
        app.UseStaticFiles();
    }

    // Entry point for the application.
    public static void Main(string[] args) => WebApplication.Run<Startup>(args);
}

2 个答案:

答案 0 :(得分:100)

你必须添加

app.UseDefaultFiles();
app.UseStaticFiles();方法中的Configure之前

有关详细信息,请参阅documentation

答案 1 :(得分:-8)

另一种方法是编辑web.config文件。添加新规则,根据您的需求。

相关问题