Is MVC2 ASP.Net URLDecoding Automatically?

So, I called Controller in MVC2 that way, and I got access to the classic querystrings just fine. Note that the second parameter thing2 is already URLEncoded, and again getting URLEncoded querystring and URLDecoding is not a problem. My example looks like this ...

http://mydomain.com/controller?thing1=1544&thing2=somethingURLEncoded

Now I'm trying to switch to the MVC2 ASP.Net way of handling parameters and make myself a nice custom MapRoute. I am testing it to see that it works with a simple test ...

http://mydomain.com/controller/Index/1544/999

I am successfully debugging the VS2010 step inside my Index method inside my controller!

Then I decided to take the next step and change the last URL parameter to URLEncoded ...

http://mydomain.com/controller/Index/1544/somethingURLEncoded

The problem that I see after doing this in my browser is that it is almost similar to MVC2. ASP.Net automatically addresses URLDecoding before I enter my Index method inside my controller.

What gives? I thought that I could first log into the controller, and secondly, make my own URL. Since the original data was encrypted by AES and had slashes in it .. before my parameter is premature, URLDecoding is not a side effect that I can schedule.

Please, help.

+2
source share
3 answers

, MVC url . URL- .

+6

, , Base64 URLEncode AES .

+1

Since ASP.NET MVC is based on the ASP.NET engine (unsurprisingly), properly encoded URLs are automatically correctly converted by the URL engine, so you never need to ask questions. Simply:

public ActionResult Index(string q)
{
    // TODO : Use the q parameter here as is without ever caring of URL decoding it.
    // It the caller of this action responsibility to properly URL encode his data
    return View();
}
0
source

All Articles