Thursday, April 30, 2020

How do I get all URL line variables in .NET Core 3+ including those which start with a dollar sign?

List<string[]> queryStringChunks = new List<string[]>(){};
string queryString = Request.QueryString.ToString();
if (queryString != null && queryString.Length > 1)
{
   queryString = queryString.Substring(1, queryString.Length - 1);
   foreach (var chunk in queryString.Split('&'))
   {
      queryStringChunks.Add(chunk.Split('='));
   }
}

No comments:

Post a Comment