473,797 Members | 2,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

disabling ValidateRequest for one textbox

Hi,

I have one textbox on the form that needs to have ValidateRequest disabled,
but it seems that it can only be enabled/disabled at a page level.

assuming I have to disable it at for the whole page, how can I invoke
ValidateRequest functionality for the other text boxes individually? I was
looking for some kind of method on I can call that says "validate this
control as if ValidateRequest were true" or a function "would this string
pass ValidateRequest "

TIA

Andy
Nov 18 '05 #1
2 2997
Microsoft has not built a field-by-field capability into ValidateRequest . In
fact, their code for validation is not "public" (its an internal class). So
its simply not available.

I built a far more aggressive system to protect against Cross Site Scripting
and SQL Injection attacks that you may want to investigate. "Visual Input
Security" (http://www.peterblum.com/vise/home.aspx) provides validators that
can be assigned to individual controls and detect script attacks.

An example of being more aggressive: It lets you define a list of HTML tags
that you want to permit on a field and will still block those tags when
illegal javascript is also embedded in them.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Andy Fish" <aj****@blueyon der.co.uk> wrote in message
news:Oo******** ******@tk2msftn gp13.phx.gbl...
Hi,

I have one textbox on the form that needs to have ValidateRequest
disabled, but it seems that it can only be enabled/disabled at a page
level.

assuming I have to disable it at for the whole page, how can I invoke
ValidateRequest functionality for the other text boxes individually? I was
looking for some kind of method on I can call that says "validate this
control as if ValidateRequest were true" or a function "would this string
pass ValidateRequest "

TIA

Andy

Nov 18 '05 #2
Thanks peter, I can't blame you for advertising your toolkit which I'm sure
is excellent, but I found a simple way to invoke the microsoft request
validation: details below for anyone who has the same problem.

download Lutz Roeder's reflector and decompile the class
System.Web.Cros sSiteScriptingV alidation, then past the code into your own
class. Then you can call IsDangerousStri ng on any text field you want to
validate. I was going to post the source here but that might mean some
people would miss out on using this fantastic tool.

Some caveats for anyone who wants to do it this way:

1. you must remove null characters from the string before calling the
validation, otherwise you could fall foul of a known IE vulnerability (see
the source for HttpRequest.Val idateString).

2. if a new version of the framework comes out with improvements to the
validation, you'll need to recreate your class

3. decompiling and reusing the source might contravene your licence
agreement for using the framework (IANAL)

Andy

"Peter Blum" <PL****@Blum.in fo> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Microsoft has not built a field-by-field capability into ValidateRequest .
In fact, their code for validation is not "public" (its an internal
class). So its simply not available.

I built a far more aggressive system to protect against Cross Site
Scripting and SQL Injection attacks that you may want to investigate.
"Visual Input Security" (http://www.peterblum.com/vise/home.aspx) provides
validators that can be assigned to individual controls and detect script
attacks.

An example of being more aggressive: It lets you define a list of HTML
tags that you want to permit on a field and will still block those tags
when illegal javascript is also embedded in them.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Andy Fish" <aj****@blueyon der.co.uk> wrote in message
news:Oo******** ******@tk2msftn gp13.phx.gbl...
Hi,

I have one textbox on the form that needs to have ValidateRequest
disabled, but it seems that it can only be enabled/disabled at a page
level.

assuming I have to disable it at for the whole page, how can I invoke
ValidateRequest functionality for the other text boxes individually? I
was looking for some kind of method on I can call that says "validate
this control as if ValidateRequest were true" or a function "would this
string pass ValidateRequest "

TIA

Andy


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3238
by: Shaun Dore | last post by:
Hi, I have a web form containing a TextBox that allows users to edit XML files. When the page is posted, the changes are saved. This worked fine until the ValidateRequest 'feature' came along in .Net 1.1 Now, I've been told that it can be disabled using the 'ValidateRequest' attribute (of Page). This works on 1.1 and is fine since I always encode and check my strings manually to ensure no malicious script can be submitted.
2
15885
by: Tim Zych | last post by:
I'm trying to stop .Net from validating data entered into a textbox. When I enter < or > .Net returns an error: potentially dangerous Request.Form value was detected from the client... so a search on google indicates a couple of options: 1. Add validateRequest = "false" in the page directive. So I add it: <%@ Page Language="vb" AutoEventWireup="false" Codebehind="addcode.aspx.vb"
3
2104
by: Umut Tezduyar | last post by:
I couln't find the code begind property on the Page object that represents the "ValidateRequest" attribute on the @Page element. There must be some property that the PageParser knows what to do when when parsing ValidateRequest. I couldn't find any information about this. Besides, it seems only can be declared on the html, and .config. What if i am a control author and want to disable ValidateRequest for some controls. For example, i dont...
0
917
by: aualias | last post by:
I have a TextBox that the user can enter html code into. I cannot send the entered text to the server without setting ValidateRequest to false. Is there a way that I can HtmlEncode() on the fly, so that the user can enter html into the text box and the encoded text gets posted to the server? ( without changing the text in the control, I cannot see how this can be done ) Or... Can I turn off ValidateRequest for only that one control?
2
1902
by: Ben R. | last post by:
Is there any way to selectively have ValidateRequest on based on the logged in user? Also, can we control what tags will be allowed? For example, I don't have a problem with my users toggling bold, but don't want them using scripting. Is there a way to customize the tags that are allowed? If not, is there any suggested alternate method for performing this sort of partial validation?
2
2067
by: \A_Michigan_User\ | last post by:
*WITHOUT* using: ValidateRequest="False" for the whole page (or my whole site).... How would I trap/detect that a textBox contains some illegal characters? (I'm using asp.net v1.1 and vb.net) Thanks.
0
1506
by: \A_Michigan_User\ | last post by:
I guess I'm not understanding this correctly. I have to set "ValidateRequest=False" for my asp.net 1.1 page that has a TextBox... so that I can avoid an error... if some user enters some html or script coding into it. (Should I HtmlEncode it with Server.htmlEncode or HttpServerUtility.HtmlEncode ???) From what I've read... I guess I'm supposed to do it this way: 1. HtmlEncode the user input that's in the TextBox. 2. Save it to the...
3
2098
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I get an error on a .net 2.0 page when I use foreign characters, such as ç or ã. Setting validateRequest=false handles this, but is there a way to keep validateRequest=true but allow foreign characters? I don't see how these would be dangerous (am I missing something here?).
2
2191
by: msch.prv | last post by:
Is there a specific method to disable field validators in a user control.from within a parent page or does it require an ad hoc approach? The page attribute ValidateRequest does not seem to be available in user controls. TIA for any inputs.
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9536
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10468
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10245
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10205
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9063
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6802
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4131
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.