Saurabh
Saurabh

Reputation:

Does ASP.NET MVC Handle *#%":?<> Characters In The URL?

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

Answers (5)

Celso Xavier Luz
Celso Xavier Luz

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

leppie
leppie

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

Matthew Flaschen
Matthew Flaschen

Reputation: 284836

RFC 1738:

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

Dykam
Dykam

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

bh213
bh213

Reputation: 6529

Take a look at this.. While it does not solve the problem, at least you know you are not alone :)

Upvotes: 0

Related Questions