日期:2014-05-17 浏览次数:20476 次
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // 路由名称 "{controller}/{action}/{id}", // 带有参数的 URL new { controller = "Home", action = "Index", id = UrlParameter.Optional } // 参数默认值 ); routes.MapRoute( "Paging", // 路由名称 "{controller}/{action}/{Tid}/{page}", // 带有参数的 URL new { controller = "Home", action = "List", Tid = UrlParameter.Optional, page = UrlParameter.Optional } // 参数默认值 ); }
public class HomeController : Controller { public ActionResult Index() { ViewBag.Message = "欢迎使用 ASP.NET MVC!"; return View(); } public ActionResult About() { return View(); } public ActionResult List(string Tid,string page) { string s = string.Format("Tid:{0},page:{1}",Tid,page); return View(s); } }
@{ ViewBag.Title = "List"; } <h2>List</h2>