Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

string.QueryString c#


  // Adding a second parameter with the same name (round 2).
  StringValues twoValues = StringValues.Concat(queryString["param2"], "my other value");
  parsedQueryString["coronavirus"] = twoValues;

  // Getting a param value
  var param2Value = queryString["param2"];
  // --> StringValues!

  param2Value.ToString(); // Get the values concatenated together
  param2Value.ToArray(); // Gets an array of strings

  // Modifying a parameter
  queryString["param1"] = "another value";
  // NOTE, if there were two values,
  // this overwrites both and leaves a single value.

  // Url Encoding the whole thing
  QueryString.Create(parsedQueryString).ToString();
  // --> "?param1=another%20value¶m2=my%20value¶m2=my%20other%20value
Source by trackjs.com #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
9+4 =