首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

增添mvc路由

2012-11-05 
添加mvc路由由于经常在cshtml页面点调试 而.net服务器会默认打开http://localhost:8861/Views/Home/Regist

添加mvc路由
由于经常在cshtml页面点调试 而.net服务器会默认打开http://localhost:8861/Views/Home/RegisterPhone.cshtml 这种网址
所以要手动改成http://localhost:8861/Home/RegisterPhone很麻烦 就想添加个路由用于测试
于是我在Global.asax的RegisterRoutes方法内默认路由下添加了一条:
routes.MapRoute(
  "CreatedByYao",
  "Views/{controller}/{action}.cshtml/{id}", //http://localhost:8861/Views/Home/RegisterPhone.cshtml
  new { controller = "Home", action = "Login", id = UrlParameter.Optional }
  );
但是停止服务重开后 还是无法找到http://localhost:8861/Views/Home/RegisterPhone.cshtml 这种页面 是不是我路由写的不对 应该是什么样的 怎么调试呢

[解决办法]
{action}.cshtml,这样不是成了
Login.cshtml
[解决办法]
对啊,你是不是应该写成

Views/{controller}/{action}/{id}.cshtml

热点排行