[ASP.NET Core MVC 入门教程笔记] MVC 04 - 配置 MVC 和中间件

本文是ASP.NET Core MVC入门教程的一部分,主要讲解如何配置MVC和中间件。内容包括修改bundleconfig.json以实现js的bundle&minify,将MVC服务注册到IoC容器,以及在ASP.NET Core管道中使用和配置MVC中间件。
摘要由CSDN通过智能技术生成

修改 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 的 ConfigureService

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值