How to update querystring in C#?

后端 未结 11 1145
野的像风
野的像风 2020-12-02 12:06

Somewhere in the url there is a &sortBy=6 . How do I update this to &sortBy=4 or &sortBy=2 on a button click? Do I need to write custom string functions to creat

11条回答
  •  有刺的猬
    2020-12-02 12:56

    I think you could perform a replacement of the query string in the following fashion on your server side code.

    NameValueCollection filtered = new NameValueCollection(request.QueryString);
    
    filtered.Remove("SortBy");
    filtered.Add("SortBy","4");
    

提交回复
热议问题