Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am looking at dealing with cross-site scripting, one solution that I came across, involves setting the validateRequest = false in either the web.config (covers the entire project) or in the @Page tag in the source of individual pages. Once this change has been made it is necessary to use the cmds:

HttpUtility.HtmlEncode
and 
HttpUtility.HtmlDecode

 

to convert the data as you are collecting/ distributing to the page front and database.

 

Another solution suggested involves employing required field validators on all text fields.

 

Has anyone used any of these methods, and what are their impressions of them.

 

Mike55.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted
I know Microsoft recommends what you wrote if your going to turn off that setting, they recommend leaving that setting on I believe. Those utility methods are pretty staight forward but it's one of those things if you have a bunch of controls you need to 'hand-roll validate' you really begin to wish .NET supported (natively) AOP.
Posted

Hi bri189a

 

From what I can see there is no general agreement on what you should do, there are a large number of suggestions but each seem to contradict the other i.e. one microsoft page said to set ValidateRequest = false and use the htmlencode and htmldecode, while another said that you shouldn't even consider setting the property to false.

 

What about employing a regular expression validator, that checks that the input is an alphanumeric character, however the problem arises in that if I want to use the "<" or ">" or any other symbol as input to a field I get an validation error.

 

Is there any possibility of catching the exception thrown by the asp.net page when it detects the input is a script?

 

Mike55.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...