NameValueCollection to URL Query?

前端 未结 12 2042
温柔的废话
温柔的废话 2020-11-28 05:36

I know i can do this

var nv = HttpUtility.ParseQueryString(req.RawUrl);

But is there a way to convert this back to a url?

v         


        
12条回答
  •  攒了一身酷
    2020-11-28 06:20

    You can use.

    var ur = new Uri("/page",UriKind.Relative);
    

    if this nv is of type string you can append to the uri first parameter. Like

    var ur2 = new Uri("/page?"+nv.ToString(),UriKind.Relative);
    

提交回复
热议问题