先看看我们例子用到的路由表
routes.MapRouteWithName( name: "ProductDetail", url: "{Platform}/Product/{ProductID}", defaults: new { controller = "Home", action = "Product"} );
- 方法1
protected internal RedirectToRouteResult RedirectToRoute( Object routeValues ) eg: return RedirectToRoute(new { controller = "Home", //控制器 action = "Product", //Action ProductID = 1, //参数 nickName = "wahaha" //参数 });
- 方法2
protected internal RedirectToRouteResult RedirectToRoute( string routeName, Object routeValues ) eg: 重定向到该路由 return RedirectToRoute("ProductDetail", new { Platform = "WeChat", ProductID = 1 });
- 方法3
protected internal RedirectToRouteResult RedirectToRoute( RouteValueDictionary routeValues ) eg: return RedirectToRoute(new System.Web.Routing.RouteValueDictionary(new { action= "Product", controller = "Home", ProductId =1 //参数 }));
- 方法4
protected internal virtual RedirectToRouteResult RedirectToRoute( string routeName, RouteValueDictionary routeValues ) eg: return RedirectToRoute("ProductDetail", new System.Web.Routing.RouteValueDictionary(new { Platform = "WeChat", ProductID = 1
}));