【问题标题】:Passing querystrings to RedirectToRouteResult (beside controller and action)将查询字符串传递给 RedirectToRouteResult(在控制器和操作旁边)
【发布时间】:2013-06-13 14:11:48
【问题描述】:

我有以下代码:

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

这将产生“/Persons/Login

如何将附加查询字符串传递给之前的代码?使其产生“/Persons/Login/?someQuerystring=someValue

【问题讨论】:

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


    【解决方案1】:

    试试这个:

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

    【讨论】:

      猜你喜欢
      • 2019-07-02
      • 1970-01-01
      • 2010-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多