Controller中利用RedirectToRoute重定向的问题

先看看我们例子用到的路由表

 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 = , //参数
nickName = "wahaha" //参数
});
  • 方法2
protected internal RedirectToRouteResult RedirectToRoute(
string routeName,
Object routeValues
) eg: 重定向到该路由 return RedirectToRoute("ProductDetail", new { Platform = "WeChat", ProductID = });
  • 方法3
protected internal RedirectToRouteResult RedirectToRoute(
RouteValueDictionary routeValues
) eg: return RedirectToRoute(new System.Web.Routing.RouteValueDictionary(new {
action= "Product",
controller = "Home",
ProductId = //参数
}));
  • 方法4
protected internal virtual RedirectToRouteResult RedirectToRoute(
string routeName,
RouteValueDictionary routeValues
) eg:
return RedirectToRoute("ProductDetail", new System.Web.Routing.RouteValueDictionary(new
{
Platform = "WeChat",
ProductID = 1 }));
上一篇:第十章 Vim程序编辑器学习(下)


下一篇:xueping wang 记录2