How to enable special characters in MVC routing?

I am using asp.net MVC 4.

These are my routes:

routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}" ); 

My current controller responds correctly to the following request:

http://localhost:2020/PrivacyUrls/Details/ct14524

How can I check URLs like these?

http://localhost:2020/PrivacyUrls/Details/*ct14524

http://localhost:2020/PrivacyUrls/Details/&ct14524

which now returns 404.

The potentially dangerous Request.Path value was detected by the client (*).

The potentially dangerous Request.Path value was detected by the client (&).

I thought to add this route, but this did not help:

  routes.MapRoute( "PivacyUrl/Details", "PrivacyUrls/Details/{*ctid}",// URL with parameters new { controller = "PrivacyUrls", action = "Details" } ); 
+6
source share
2 answers

In web.config:

 <system.web> <httpRuntime requestPathInvalidCharacters="" requestValidationMode="2.0" /> <pages validateRequest="false" /> </system.web> 

Blissfully stolen from fooobar.com/questions/22825 / ...

+8
source

The answer did not help me. I had to use:

 [ValidateInput(false)] public ActionResult Index... 

Hope this helps others.

0
source

All Articles