views:

97

answers:

2

Hi there.

I currently have this route defined (among others): "{controller}/{action}/{id}/{designation}" being:

  • "id" my primary key
  • "designation" only used for SEO and not taken into account.

now my problem is: "http://server/Home/Index/1/teste" works but "http://server/Home/Index/1/teste " with a space in the end doesn't.

IIS is giving me a 404 and mvc is not even starting for this request.

Anyone experienced this behavior? Anything I need to change?

With best regards

A: 

Space is an invalid character in URL's. The browser should not even send it.

If you're calling this in code, try using HttpUtility.UrlEncode( path ) before sending / redirecting.

Chad Grant
+2  A: 

Space cannot be used as a plain text character in a url. You have to encode it as:

%20

E.g.

http://www.testDomain.com/test%20page
Penfold
The main problem is not if the space is encoded but if the space is appearing in the end of the url.for the same route, Controller Home, Action Foohttp://server/Home/Foo/bar%20bar andhttp://server/Home/Foo/bar%20bar/ workshttp://server/Home/Foo/bar%20bar or http://server/Home/Foo/bar%20bar/ does not!This is the main question. Why the %20 or " " space is not allowed in the end of a url.