Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error : potentially dangerous Request. how can able to allow the url containing a (&)

Tags:

c#

asp.net

this is my the url-

http://localhost:4566/PropertyMap/project/ackruti-gardenia-dahisar-&-beyond-mumbai

and I got error as-

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: A potentially dangerous Request.Path value was detected from the client (&).

Stack Trace:

[HttpException (0x80004005): A potentially dangerous Request.Path value was detected from the client (&).]
   System.Web.HttpRequest.ValidateInputIfRequiredByConfig() +9673044
   System.Web.ValidateRequestExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +35
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

How can i solve it?

like image 585
Pradeep Avatar asked Dec 16 '22 11:12

Pradeep


2 Answers

The ampersand (&) has special meaning in a URL, being used to separate elements within Query String and Fragment parts. This usage is forbidden by default because it's typical for hackers to probe around like this, trying to discover exploits.

To avoid this you need to use URL encoding on the path, so the ampersand is encoded to %26, making the final URL:

http://localhost:4566/PropertyMap/project/ackruti-gardenia-dahisar-%26-beyond-mumbai

Since you do not specify where the URL is constructed I cannot help you with how to encode it properly - implementation differs per language.

like image 193
Niels Keurentjes Avatar answered Jan 21 '23 16:01

Niels Keurentjes


Use the HttpUtility.UrlEncode() method

like image 39
JourneyThroughCode Avatar answered Jan 21 '23 14:01

JourneyThroughCode