2016-03-03 72 views
33

我已經創建了.NET核心的 Web應用程序的默認頁,在wwwroot我有的index.html這不加載默認頁面,只加載時,我把它叫做明確。的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); 
} 

回答

74

你有Configure方法app.UseStaticFiles();之前添加

app.UseDefaultFiles(); 

有關更多詳細信息,請參閱documentation

+0

好的!你是對的。它正在工作,訂單起着很大的作用,我不喜歡,但... – DAG

+3

這裏是附加信息。例如要添加哪個庫以及哪個訂單。 http://www.talkingdotnet.com/make-index-html-startup-file-in-aspnet-core/ –

+0

有沒有一個我們可以看到的頁面,哪個中間件必須被調用?或者,只是谷歌這一切... – Legends

-5

另一種方法是編輯你的web.config文件。添加新的規則,相應您的需求。