2016-03-03 77 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文件。添加新的规则,相应您的需求。