Carlos Sobrinho
Carlos Sobrinho

Reputation:

Space in routing gives 404

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

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

Upvotes: 3

Views: 822

Answers (3)

Kamarey
Kamarey

Reputation: 11069

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.

Upvotes: 0

Chad Grant
Chad Grant

Reputation: 45382

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.

Upvotes: 0

Richard Hooper
Richard Hooper

Reputation: 819

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

Upvotes: 2

Related Questions