• Register
0 votes
69 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 64 views
64 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.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
0 answers 23 views
23 views
Problem: I have basic knowledge on ASP.Net and Database Connection. Currently I am receiving the below error if I try to run my code: System.Configuration.ConfigurationErrorsException: 'The configuration section cannot contain a CDATA or text element'. My application ... SSPI;Initial Catalog=TestData" providerName="System.Data.SqlClient"/> Kindly help me in fixing above ASP.Net related error ASAP.
asked Jun 22, 2020 Raphael Pacheco 4.9k points
1 vote
1 answer 144 views
144 views
Problem : Recently I was told to prepare the C# as I am in pool of new projects. So I have started learning C#. But because of some unknown reason to me now I am facing below error. &ldquo;Make sure that the controller has a parameterless public constructor&rdquo;. As I am very new to C# so I am unable to understand the above error. I need help from someone who can fix the above error.
asked Mar 31, 2020 morrisBson 3.2k points
0 votes
1 answer 10 views
0 votes
1 answer 14 views
14 views
Problem: I am naive to Asp.Net.I am having a weird looking problem where I am trying to open up my ASP.NET MVC application but I am receiving the below ASP.NET error page which says: Server Error in '/' Application. The resource cannot be found. Description: ... unknown reason to me it seems like it is actually searching for the .aspx file. Please guide me if you think I am missing something.
asked Aug 19, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 115 views
115 views
Problem : I have recently installed a website on my local machine using IIS 7 successfully. But when I tried to deploy it on the live server, I got a following error: "The page cannot be displayed because an internal server error has occurred" Nothing else. Using a same IIS 7 on live and also set to have the Detailed errors in Error Pages module, but still getting a same. What can be the reason?
asked Jan 28, 2020 jwilliam 3.9k points
1 vote
1 answer 43 views
43 views
Problem : While binding the dropdown in MVC, I often face following error: There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key country. Please find below my View for your reference : @Html.DropDownList("country", (IEnumerable<SelectListItem>)ViewBag ... .countryid.ToString() }); } ViewBag.mycountrydrop = myitem8; return View(); I do not know how to resolve above error.
asked Dec 28, 2019 alecxe 7.5k points
0 votes
2 answers 205 views
205 views
Problem : I am new to ASP MVC and I am facing one error. I am trying to access the Model's Data from the Controller section and I am getting following error when I try to create a Movie as a part of the exercise, whenever I try to click on the link "Create New" I ... am using the Visual Studio 2012 RC I am not sure if this is the root cause of my issue.Please let me know the solution for my issue.
asked Dec 3, 2019 alecxe 7.5k points
1 vote
1 answer 12 views
12 views
Problem: I am having fundamental knowledge on C#. Currently I am unable to connect to the HTTPS server with the use of WebRequest as I am facing below error message: "The request was aborted: Could not create SSL/TLS secure channel." I understand that my ... my server never really validates a certificate and it fails with a above error. Kindly guide me in fixing above certificate related error.
asked Jun 30, 2020 Raphael Pacheco 4.9k points