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

前端 未结 30 2143
刺人心
刺人心 2020-11-21 05:24

Every time a user posts something containing < or > in a page in my web application, I get this exception thrown.

I don\'t want to go

30条回答
  •  离开以前
    2020-11-21 05:53

    There's a different solution to this error if you're using ASP.NET MVC:

    • ASP.NET MVC – pages validateRequest=false doesn’t work?
    • Why is ValidateInput(False) not working?
    • ASP.NET MVC RC1, VALIDATEINPUT, A POTENTIAL DANGEROUS REQUEST AND THE PITFALL

    C# sample:

    [HttpPost, ValidateInput(false)]
    public ActionResult Edit(FormCollection collection)
    {
        // ...
    }
    

    Visual Basic sample:

     _
    Function Edit(ByVal collection As FormCollection) As ActionResult
        ...
    End Function
    

提交回复
热议问题