Saturday, March 22, 2014

Special characters in action parameters : MVC handling


Special Characters in URL:

We have one scenario in which our complete sign up URL was containing encrypted key. Encrypted key was base64 encoded string which was generated by a crypto algorithm. This encrypted key was having special character like %,#,<,>,/,!,@&* any of them in one or more combinations.

So our sign up URL was forming something like this:

http://mysite/completesignup/ADSD$%@#$sdfdf?sdfsdf&^sdf++==/dfdfdfdf?/

And this link was sent to potential users in their email. So if user wants to complete its sign up operation.

But due to default request filter settings of IIS request pipeline user was getting error 404.1 Bad Request.

to fix this first step was to specify following in application web.config.


 <security>
            <requestFiltering allowDoubleEscaping="True" />
</security>

This fixed issue when ever we have double escaping

Another point to understand here is instead of passing special characters in action parameters we should pass it as query string.

No comments:

Post a Comment