• Register
0 votes
99 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.

7 5 2
3,870 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.

9 7 4
38,600 points

Related questions

0 votes
1 answer 8 views
8 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 128 views
128 views
Problem: I am completely new to ASP .net core. I guess it is giving me the dependency injection error as shown below: InvalidOperationException: Unable to resolve service for type 'Spinit ... ) Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
asked Aug 17, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 3 views
3 views
Problem: I'm trying to send a call using Ajax but in Chrome it is a rising error: The server responded with a status of 500 Thanks
asked Mar 20 ummesalma 24.5k points
0 votes
1 answer 8 views
8 views
Problem : why this is still happining : Failed to load resource: the server responded with a status of 500 (internal server error).
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
1 answer 3.2K views
3.2K views
Problem : I want to send a call using ajax but in Chrome getting following error Failed to load resource: the server responded with a status of 500 (internal server error) But for firefox getting no error. I also tried to record the ajax call in firebug but there is no call request in ... function (msg) { }, error: function (xhr, status, error) { alert(error.responseTextss); } }); }); }); }); }
asked Nov 22, 2019 peterlaw 6.9k points
0 votes
1 answer 7 views
7 views
Problem: I got my project created well, next step adding a View from an existing Controller, I got hit by a message box error saying : Error : There was an error running the selected code generator: 'Invalid pointer (Exception from HRESULT:0x80004003(E_POINTER))' What's causing this problem and What is the solution for it ?
asked Mar 19 ummesalma 24.5k points
0 votes
1 answer 4 views
4 views
Problem: Please solve it &hellip; Because I am unable to find out the solution of this site can&rsquo;t be reached the connection was reset
asked Mar 18 Ifra 24.4k points
0 votes
1 answer 5 views
5 views
Problem: Can anyone tell me the solution of this problem? This site can&rsquo;t be reachedthe connection was reset.
asked Mar 18 Ifra 24.4k points
0 votes
1 answer 8 views
8 views
Problem: The service call returns the message: System.ServiceModel.ServiceActivationException: The requested service, 'http://localhost:83/ABCStaticData/StaticDataService.svc' could not be activated. See the server's diagnostic trace logs for more information.
asked Mar 20 ummesalma 24.5k points
1 vote
1 answer 4 views
4 views
Problem: I am facing this error please help : 500 internal server error. iis 7
asked Mar 20 PkGuy 13.1k points