public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
); } public class HomeController : Controller
{
public ActionResult About(int? id1,string name,int? id)
{
return View();
}
}
问题:
输入http://localhost:xx/Home/about,可以正常显示
http://localhost:xx/Home/about/1/2/3,找不到页面
http://localhost:xx/Home/about?id1=1&name=2&id=3,可以正常显示
怎样才可以在地址栏里面用/隔开各个参数并正确路由,也就是要第二种输入可以找到页面
解决方案 »
- 数据库连接的问题
- SQL语句问题?
- 关于<script />与<script ></script>的区别?
- ASP.NET2.0(C#)中如何实现WEB打印?
- 点击leftFrame中的treeview时刷新mainFrame页面,为什么还是不行?
- 求救页面跳转问题!!!
- @@@ win2003下如何为ASP.Net辅助线程指定运行用户 @@@
- 300分求能抓取网页中的图片全路径到一个字符串数组的正则表达式!
- 纳闷DataGrid PageIndexChanged事件不执行
- ASP.NET MVC EasyUI datagrid
- GridView分页后怎么记忆每页所选中的RadioButton
- dataset转换数组
new { controller = "Home", action = "about" });加到你的默认路由前面。view:
Html.ActionLink("test","你的参数","Home")
"xxx", // Route name
"{id1}/{name}/{id}.html", // URL with parameters
new
{
controller = "Home",
action = "About"
} // Parameter defaults
);
"test", // 路由名称
"Home/about/{id}/{name}/{ids}", // 带有参数的 URL
new { controller = "Home", action = "about"} // 参数默认值
);
加到你的默认路由前面。
view:
Html.ActionLink("test","About/1/2/3","Home")