Replace item in querystring

前端 未结 11 1481
甜味超标
甜味超标 2020-12-11 01:23

I have a URL that also might have a query string part, the query string might be empty or have multiple items.

I want to replace one of the items in the query string

11条回答
  •  [愿得一人]
    2020-12-11 01:26

    I agree with Cerebrus. Sticking to the KISS principle, you have the querystring,

    string querystring = myURI.Query; 
    

    you know what you are looking for and what you want to replace it with.

    So use something like this:-

    if (querystring == "") 
      myURI.Query += "?" + replacestring; 
    else 
      querystring.replace (searchstring, replacestring); // not too sure of syntax !!
    

提交回复
热议问题