C# ASP.NET MVC Manually Accessing Request.Form & Potentially Dangerous values

前端 未结 1 1585
有刺的猬
有刺的猬 2021-01-15 00:03

I\'m serializing and saving form and query string data to a database for each user request. This particular submitted model already has the [AllowHtml] attribute and submit

相关标签:
1条回答
  • 2021-01-15 00:53

    Accessing values with Request.Form[] will trigger request validation (hence the exception). You can use the Unvalidated property of HttpRequest to get the request values without triggering validation.

    Replace

    Request.Form[k]
    

    with

    Request.Unvalidated.Form[k]
    

    Use with caution - from the documentation:

    Security Note: If you use this property, you must manually check the data for potential cross-site scripting attacks.

    0 讨论(0)
提交回复
热议问题