传递查询字符串以RedirectToRouteResult(控制器和操作旁) [英] Passing querystrings to RedirectToRouteResult (beside controller and action)

查看:1073
本文介绍了传递查询字符串以RedirectToRouteResult(控制器和操作旁)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的code:

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

这会产生 /人/登录

我怎么能传递一个aditional的查询字符串为previous code?因此,它生产的 /人/登录/?someQuerystring = someValue中

How can I pass an aditional querystring to the previous code? so that it produces "/Persons/Login/?someQuerystring=someValue"

推荐答案

试试这个:

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

这篇关于传递查询字符串以RedirectToRouteResult(控制器和操作旁)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆