Reputation: 43
How can I get the raw value corresponding to a parameter from a query string in ASP.NET MVC (5.2.7) ?
Currently, I am only able to get the decoded value.
For example, with the query string p=lol%20cat
, the code below returns "lol cat" :
string decoded = Request.QueryString["p"]; // "lol cat"
When my query string is p=lol%20cat
, I want to get "lol%20cat".
Also, if it is p=lol+cat
, I want to get "lol+cat".
I could build something myself using System.Web.HttpRequestBase
or System.Uri
but I would prefer to use something reliable, built-in the .NET Framework.
Upvotes: 2
Views: 836
Reputation: 49
Try using
Request.Url.Query
This returns the raw querystring as a string.
Upvotes: 1