video
修改 bundleconfig.json 对 js 进行 bundle&minify:
// js{"outputFileName": "wwwroot/js/all.min.js","inputFiles": ["node_modules/jquery-slim/dist/jquery.slim.js","node_modules/popper.js/dist/js/popper.js","node_modules/bootstrap/dist/js/bootstrap.js","wwwroot/js/site.js"],"minify": {"enabled": true,"renameLocals": true},"sourceMap": false},{"outputFileName": "wwwroot/js/vendor.js","inputFiles": ["node_modules/jquery-slim/dist/jquery.slim.js","node_modules/popper.js/dist/js/popper.js","node_modules/bootstrap/dist/js/bootstrap.js"],"minify": {"enabled": false}}
设置 MVC 和中间件
- 注册 MVC 服务到 IoC 容器
- 在 ASP.NET Core 管道里使用并配置 MVC 中间件
注册 MVC 服务仅需在 Startup 的 ConfigureServices 方法顶部加一句 services.AddMvc(); 即可。
通过下面的代码在 Configure 方法里面使用和配置 MVC 和中间件:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILogger<Startup> logger){if (env.IsDevelopment()){app.UseDeveloperExceptionPage();}app.UseStatusCodePages();// 使用 wwwroot 下的静态文件app.UseStaticFiles();// 使用 MVC 并配置路由app.UseMvc(routes =>{routes.MapRoute(name: "default",template: "{controller=Home}/{action=Index}/{id?}");});}
