參考:https://jingyan.baidu.com/article/6079ad0e3e212168fe86db75.html
在Startup.cs的Configure添加
app.UseFileServer();
示例:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); //開啟index.html app.UseFileServer(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
注:目前這一夠代碼的位置沒研究,應該是隨便就行