2

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.

1
  • simply you cant you must pass two value or one value without spaces Commented Dec 9, 2020 at 10:24

1 Answer 1

1

Try using

Request.Url.Query 

This returns the raw querystring as a string.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer. However, I have to search in the string (split, etc) myself. Sure, I can do it but I don't want to reinvent the wheel and it would be better if something like Request.EncodedQueryString["p"] exists.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.