setting query string in redirecttoaction in asp.net mvc

前端 未结 2 902
谎友^
谎友^ 2020-12-17 02:14

I have to do a redirecttoaction call in asp.net mvc view with varying params, extracted from the referrer page of the view (the status of a grid).

I hav

2条回答
  •  遥遥无期
    2020-12-17 02:40

    To create a generic solution convert your querystring to a Dictionary and at the dictionary to the RouteValueDictionary.

    var parsed = HttpUtility.ParseQueryString(temp); 
    Dictionary querystringDic = parsed.AllKeys
        .ToDictionary(k => k, k => (object)parsed[k]); 
    
    return RedirectToAction("Index", new RouteValueDictionary(querystringDic)); 
    

提交回复
热议问题