asp.net-mvc-4 - 将查询字符串传递给RedirectToRouteResult(在 Controller 和操作旁边)

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

我有以下代码:

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


那将产生“ /Persons/Login

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

最佳答案

试试这个:

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

关于asp.net-mvc-4 - 将查询字符串传递给RedirectToRouteResult(在 Controller 和操作旁边),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17150647/

相关文章:

c# - 无法访问 HttpContext.Current

c# - 如何在 MVC 4 中显示来自路径的图像?

c# - MVC 自定义路由。 DataTokens ["Namespaces"] 被忽略

asp.net - RedirectToRoute 应该如何使用?

asp.net-mvc - 如何在 MVC 中使用 RedirectToRoute ("routeName")?

c# - Azure:启动远程调试器失败

asp.net-mvc-4 - ScriptBundle 不渲染 VirtualDirectory 中的脚本

asp.net-mvc - ASP.NET MVC 3 : RouteExistingFiles = true seems to have no effect

c# - MVC3 路由 - 删除参数