• Register
0 votes
157 views

Problem :

I have got the legacy code issue that requires that I support the random urls as if they were requests for a home page. Some of the URLs have the characters in them that generate the below error 

"A potentially dangerous Request.Path value was detected from the client (&)"

This site is written with the ASP.Net MVC 3 (in C#) and is currently running on IIS 7.5.

Below is an example URL.

http://mywebsite.com/Test123/This_&_That

Below is how I have my catch-all route setup (I have the other routes to catch specific pages)...

routes.MapRoute(
    "Default", // My Route name
    "{garb1}/{garb2}", // My URL with parameters
    new { controller = "Website", action = "Home", garb1 = UrlParameter.Optional, garb2 = UrlParameter.Optional } // Parameter defaults
);

I have added below things to the web.config file.

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

I have also Added a ValidateInput attribute to my action that should be catching the urls.

3.9k points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

While you could try below settings in the config file

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

I would avoid using the characters like '&' in my URL path will replace them with underscores.

Hope this will fix your error.

38.6k points

Related questions

0 votes
1 answer 49 views
49 views
Problem: Am trying to click save button to update what I have in text editor using ckeditor but I got this error A potentially dangerous Request.Form value was detected from the client (OPTION_VALUE=" Welcome to the Na..."). The controller is shown below Controller public ActionResult ... "></script> <script> $(function () { CKEDITOR.replace('editor1'); }); </script> } Please what do I do.
asked Apr 30 Yeamin 23.5k points
0 votes
1 answer 40 views
40 views
Problem: I am receiving the rather self explanatory error. Should I manually encode / decode the special characters? Or is there a best practice for doing this, I would like to avoid using query strings. - but it may be an option.
asked Apr 30 salim1 60.6k points
0 votes
1 answer 47 views
47 views
Problem: Every time a user publishes something that it contains < or >on a page of my webapp, I get this exception. I don't want to get into the discussion about how smart to throw an exception or crash an entire webapp because someone entered a character in a textbox, but I'm ... in HTML. So the one .Textin my textbox will be something & lt; html & gt; Is there a way to do this from a handler?
asked Feb 26 sasha 16.2k points
0 votes
1 answer 13 views
13 views
Problem: I am receiving the rather self explanatory error,"A potentially dangerous Request.Path value was detected from the client (*). " I will appreciate any help.
asked May 1 salim1 60.6k points
0 votes
1 answer 7 views
7 views
Problem: Where should I look for help with this issue : To allow get requests set jsonrequestbehavior to allowget?
asked Jun 24 Rada Gracelynn 104k points
0 votes
1 answer 16 views
16 views
Problem: This is something I've tried but hasn&rsquo;t had much luck with: Potentially dangerous request form value was detected from the client .
asked Jun 17 akhi 125k points
0 votes
1 answer 105 views
105 views
Problem: Need help with this : A potentially dangerous request.form value was detected from the client.
asked Jun 17 Priscilla Gurpreet 74.7k points
0 votes
1 answer 6 views
6 views
Problem: Is there a way through this : A potentially dangerous request.querystring value was detected from the client
asked Jun 15 nila 121k points
0 votes
1 answer 5 views
5 views
Problem: No http handler was found for request type get?
asked Jul 4 Mezbah 130k points
0 votes
1 answer 12 views
12 views
Problem: Can anyone assist me with this issue : One or more validation errors were detected during model generation?
asked Jun 18 Rada Gracelynn 104k points