【问题标题】:pass multiple query string values in asp.net MVC在 asp.net MVC 中传递多个查询字符串值
【发布时间】:2017-04-16 04:38:56
【问题描述】:

Routeconfig 中有如下路由

routes.MapRoute(
                name: "WithParams",
                url: "{controller}/{action}/{langue}/{AffID} ",
                defaults: new { controller = "Home", action = "Index", AffId = "", langue = "" }
            );

我正在尝试从系统的某些部分调用此路由。

Response.RedirectToRoutePermanent("WithParams", new RouteValueDictionary { AffId :123,langue:"EN" });

出现语法错误,如何在上述重定向中传递查询字符串参数。

【问题讨论】:

    标签: asp.net-mvc asp.net-mvc-4 c#-4.0 routes


    【解决方案1】:

    试试这个:

    return RedirectToRoutePermanent("WithParams", new { AffId = 123, langue = "EN" });
    

    【讨论】:

      【解决方案2】:

      试试这个:

        Dictionary<string,string> dictionary = new Dictionary<string, string>();
              dictionary.Add("AffId", "58");
              dictionary.Add("langue", "EN");
      
      
              Response.RedirectToRoutePermanent("WithParams", new RouteValueDictionary(dictionary));
      

      【讨论】:

        猜你喜欢
        • 2014-05-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-09-19
        • 1970-01-01
        • 2012-02-27
        • 2016-09-18
        • 1970-01-01
        相关资源
        最近更新 更多