A potentially dangerous Request.Path value was detected from the client

1

I'm trying to submit an action with a parameter like this:

 <a href="@Url.Action(@"Create/?reference=01/04/2016", "Cobranca")"

But it generates a URL like this:

Cobranca/Create/%3freference%3d01/04/2016

And causes the error:

A potentially dangerous Request.Path value was detected from the client 

I put the following codes in web.config:

 <pages validateRequest="false" />
 <httpRuntime targetFramework="4.5" requestPathInvalidCharacters="" />
<system.webServer>
    <security>
      <requestFiltering allowDoubleEscaping="true"/>
    </security>

It stopped this error but now of error 404 being that the URL should be:

Cobranca/Create/?reference%3d01/04/2016

or better

Cobranca/Create/?reference=01/04/2016
    
asked by anonymous 02.03.2016 / 14:42

1 answer

1

What does your Create action expect to receive parameter? A string named reference or a DateTime named reference ?

In addition, it is a good practice to use the third parameter of Url.Action() to pass the route values, so ASP.NET will install Url and its parameters for you:

<a href="@Url.Action("Create", "Cobranca", new { reference = "01/04/2016"})"/>

If reference is a date. just replace the fixed string "01/04/2016" with your date.

    
02.03.2016 / 18:16