• Register
Log In
0 votes

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.


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

    "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.

        <pages validateRequest="false" />
        <httpRuntime requestValidationMode="2.0" />

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

3.9k points

1 Answer

0 votes

Solution :

While you could try below settings in the config file

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

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

Hope this will fix your error.

36.1k points

Related questions

0 votes
1 answer 28 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
1 vote
1 answer 29 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 morrisBson 3.2k points
0 votes
1 answer 45 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 jwilliam 3.9k points
1 vote
1 answer 25 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 62 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