Passing querystrings to RedirectToRouteResult (beside controller and action)

谁都会走 提交于 2019-11-30 22:12:29

问题


I have the following code:

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

That will produce "/Persons/Login"

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


回答1:


Try this:

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


来源:https://stackoverflow.com/questions/17150647/passing-querystrings-to-redirecttorouteresult-beside-controller-and-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!