views:

178

answers:

1

I am working on a ASP.NET MVC2 project. The problem is when a string which would be rewritten into URL that contains special character such as backslash or question mark. That will make the URL wrong, even I have encoded it before.

For example:

  1. I have a product id "p001\2-2".
  2. I encoded it into "p001%5C2-2"
  3. The URL http://domain.com/Product/p001%5C2-2 will response HTTP Error 400 - Bad Request.

How can I get it correct?

+1  A: 

Try to use Html.Encode to resolve your backslash. If the backslash is the only 'special' character in your id, you could use Replace("%5C","\").

Have you checked your routingMap? there has to be a route like

Product/{prodictID}

Tobi