RouteConfig.cs 代码如下:

 public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); //自定义路由标签
routes.MapMvcAttributeRoutes(); //默认路由
//routes.MapRoute(
// name: "Default",
// url: "{controller}/{action}/{id}",
// defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
// namespaces: new string[] { "WebTest.Controllers" }
//);
}
}

Controller自定义路由标签:

 [RoutePrefix("Test")]
public class ProductController : Controller
{ [HttpGet,Route("Index")]
public ActionResult Index(int? pageIndex=,int? pageSize=)
{
ProductService service = new ProductService();
int index = Convert.ToInt32(pageIndex);
int size = Convert.ToInt32(pageSize);
var list = service.GetList(index, size);
ViewBag.products = list;
return View();
} [HttpGet,Route("Demo")]
public ActionResult One()
{
List<UserModel> list = new List<UserModel>();
for (int i = ; i < ; i++)
{
list.Add(new UserModel()
{
Id = i,
Name = "test"+i,
Password = ""
});
}
ViewBag.Users = list;
return View();
}
}

最新文章

  1. CocoaPod 使用方法
  2. POJ1190生日蛋糕[DFS 剪枝]
  3. dd命令使用详解
  4. 车牌识别LPR(五)-- 一种车牌定位法
  5. sql批量删除wordpress所有日志修订revision
  6. C++遍历目录,并把目录里超过7天的文件删除(跨平台windows&amp;linux)
  7. Invalid segment BIN$xxx and dba_recyclebin was empty (回收站空,释放无效的BIN$xx空间)
  8. Eratosthenes筛选法计算质数
  9. C#多线程编程(2)-- async,await基本用法
  10. org.apache.poi.ss.usermodel 类操作excel数据遗漏
  11. mysql进阶(六)模糊查询的四种用法介绍
  12. 第十六节,OpenCV(学习五)边缘检测
  13. RocketMQ基本概念
  14. 【转帖】Linux的历史----Linux内核剖析(一)
  15. 洛谷 P1110 [ZJOI2007]报表统计 解题报告
  16. 阿里P6大牛给予Java初学者的学习路线建议
  17. 如何为linux系统设置全局的默认网络代理
  18. Spring Boot学习笔记:JavaMailSender发送邮件
  19. statefulSet + headless service 学习记录 service :selector --&gt; template :label
  20. IT软件外包行业深入分析:现状、前途、趋势、待遇 什么是软件外包 外包公司是怎么工作的 软件外包公司的面试 软件外包公司需要什么样的人

热门文章

  1. Jupyter Notebook 编辑器美化
  2. InnoDB,5项最佳实践,知其所以然?
  3. SQL表的基本操作
  4. 洛谷P2762 太空飞行计划问题
  5. 【CF1154】题解
  6. java面试——多线程
  7. webpack 非严格模式设置 npm i babel-plugin-transform-remove-strict-mode
  8. HTTP属性管理器 初探
  9. c++ sort
  10. CodeChef - BLACKCOM 可行性dp转最优化树dp