3

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

3 Answers3

2

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
Richard Hooper
  • 809
  • 1
  • 12
  • 27
  • 4
    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 Foo http://server/Home/Foo/bar%20bar and http://server/Home/Foo/bar%20bar/ works http://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. –  May 04 '09 at 08:36
0

Look at this post:

"The resource cannot be found." error when there is a "dot" at the end of the url

it talks about similar problem with '.' (dot) character at the end of a url. Think it's the same problem as yours.

Community
  • 1
  • 1
Kamarey
  • 10,832
  • 7
  • 57
  • 70
0

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
  • 44,326
  • 9
  • 65
  • 80