Reputation:
I am new to ASP.NET MVC. I am getting an error when i use these characters - *#%":?<>
- in URL.
My question is - Does ASP.NET MVC handle *#%":?<>
characters in the URL?
Upvotes: 2
Views: 1865
Reputation: 179
Use encode in url parameter. Example:
javascript - window.location = 'path?parameter=' + encodeURIComponent(value);
Razor - @Url.Action("Action", new { parameter=Uri.EscapeUriString(@value) })"
Upvotes: 0
Reputation: 117250
No, it does not work, even when you encode them.
It is a stupid limitation in ASP.NET.
They do work in the querystring part though, just not the path part.
Upvotes: 1
Reputation: 284836
Thus, only alphanumerics, the special characters "
$-_.+!*'(),
", and reserved characters used for their reserved purposes may be used unencoded within a URL.
Of the characters you listed, only * " and - can theoretically be used unencoded. In practice, many sites would encode all the characters you listed.
Upvotes: 1
Reputation: 10290
Look over here: http://www.w3schools.com/TAGS/ref_urlencode.asp
If you want the chars to be transferred as plain chars, you have to encode them, as they have a meaning in urls.
Upvotes: 0