UseFileServer()的使用NETCORE设置默认静态资
2021-01-11 本文已影响0人
醉酒的姑娘
//识别wwwroot目录下的任何静态资源文件,默认打开index.html页面
app.UseFileServer();
image.png
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
//app.UseHttpsRedirection();
app.UseStaticFiles();
//app.UseCookiePolicy();
//会识别wwwroot目录下的任何静态资源文件,默认打开index.html页面
app.UseFileServer();
//mvc的路由设置
//app.UseMvc(routes =>
//{
// //routes.MapRoute(
// // name: "default",
// // template: "{controller=Home}/{action=Index}/{id?}");
//});
}
image.png