XSS Problem with asp.net or in asp.net mvc

. Friday, September 2, 2011
  • Agregar a Technorati
  • Agregar a Del.icio.us
  • Agregar a DiggIt!
  • Agregar a Yahoo!
  • Agregar a Google
  • Agregar a Meneame
  • Agregar a Furl
  • Agregar a Reddit
  • Agregar a Magnolia
  • Agregar a Blinklist
  • Agregar a Blogmarks

Hi Friends,

If you receive message like this :


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


Whenever you write html or other scripting inside textbox or other html input field & when the form get posted on server the script is detected as security vulnerability(commonly known as XSS) and html inbuilt validation in applied on such scripts hence this message get generated which avoids script to run on server side.

but sometimes this could also be possible that you want to post such kind of script through input box.

so you can apply following things to Page directive in asp.net


validateRequest="false"


if you are using asp.net mvc then you can do by writing ValidateInput Attribute to "False" before your action as follows :


ValidateInput(false)
you action goes here...


also if you are using 3.5 or above framework then you need to specify version 2.0 in httpruntime inside web.config as follows:

<system.web>
    <httpruntime requestvalidationmode="2.0">
    </httpruntime>
</system.web>





0 comments: