将查询字符串传递给RedirectToRouteResult(在控制器和操作旁边)

时间:2013-06-17 14:58:16

标签: asp.net-mvc-4 asp.net-mvc-routing redirecttoroute

我有以下代码:

var routeDictionary = new RouteValueDictionary {{"action", "Login"}, {"controller", "Persons"}};
filterContext.Result = new RedirectToRouteResult(routeDictionary);

这将产生“/Persons/Login

如何将aditional查询字符串传递给之前的代码?这样它就会产生“/Persons/Login/?someQuerystring=someValue

1 个答案:

答案 0 :(得分:35)

试试这个:

filterContext.Result = new RedirectToRouteResult(
    new RouteValueDictionary {
        { "action", "login" },
        { "controller", "persons" },
        { "someQuerystring", "someValue" }
    }
);
相关问题