473,806 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ValidateRequest customization

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?

-Ben
May 17 '06 #1
2 1903
On Wed, 17 May 2006 07:30:03 -0700, Ben R. <be**@newsgroup .nospam>
wrote:
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?

-Ben


For your first quesiton, you could have a customvalidator , something
like this:

protected void CustomValidator 1_ServerValidat e(object source,
ServerValidateE ventArgs args)
{
MembershipUser mu = Membership.GetU ser();
if (!Roles.IsUserI nRole("RoleOfIn terest"))
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}

}
Peter Kellner
http://peterkellner.net
May 17 '06 #2
Hi Ben,

As for the "RequestValidat ion" setting, it is controlled by @Page
directive(valid ateRequest attribute). Also, we can programmtically enable
RequestValidati on through the "HttpRequest.Va lidateInput" method. e.g.

======in global.asax==== =====
void Application_Beg inRequest(objec t sender, EventArgs e)
{
HttpContext.Cur rent.Request.Va lidateInput();
}
=============== ==========

However, the above approaches only utilize the built-in validation code
logic, and the ASP.NET framework doesn't allow user to customize the
validation logic. If you do want to perform custom validation on the
ASP.NET request's data collection, you can consider the following options:

1. Turn all request validation on the whole page request, and perform
individual validation on the input fields in the web page. For example, we
can use validation control to validate TextBox controls.

#How To: Use Regular Expressions to Constrain Input in ASP.NET
http://msdn.microsoft.com/library/en...1.asp?frame=tr
ue
2. We can do the request validation ourselves completely. The following
msdn article has demonstrated how to implement own request validation in
ASP.NET 1.0(which doesn't support validateRequest naturally). You can
reference to its code logic.

#Adding Cross-Site Scripting Protection to ASP.NET 1.0
http://msdn.microsoft.com/library/en...rotection.asp?
frame=true

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


May 18 '06 #3

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

Similar topics

1
20726
by: mar | last post by:
Does anybody know what configuration section should i set to false here. I also tried setting the page directive to false but that didn't fix it. Thanks! mc A potentially dangerous Request.Form value was detected from the client (ResultInput="...="1.0"?> <ResultData xmlns:xs...").
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.
1
1345
by: Benny | last post by:
Hello Experts, If the contents of a text box containing a html tag like formmated characters, i.e. <hello>, and if the validateRequest is set to true, it gives an error when post back: A potentially dangerous Request.Form value was detected from the client. Just wondering what are the drawbacks if the validateRequest is set to true? Under what situations should the validateRequest set to true or false? Thanks,
4
6377
by: Ray Williams | last post by:
I have a specific page that I have chosen to disable the .NET 1.1 validateRequest options by setting the page directive attribute of "validateRequest" from true to false. I manually validate all controls within this page. This page includes a UserControl which contains a textbox. It appears that the validateRequest attribute is not propagated to the usercontrol when the page is processed. This results in the standard "potentially dangerous"...
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"
8
1869
by: Max Metral | last post by:
Ok, I have a global page class derived from System.Web.UI.Page, let's call it BasePage. I have another class derived from that called MemberPage. It checks the Form collection if it's a post for some "common" fields. Now, I have an aspx page whose code behind derives from BasePage, and which sets ValidateRequest=False in the page directive of the aspx. I can post <script> tags and such with no problems. However, when I make the...
2
2998
by: Andy Fish | last post by:
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...
4
2152
by: Dave H | last post by:
If put this into my Web.config. Shouldn't this turn off the ValiateRequest app wide? <configuration> <system.web> <pages buffer="true" validateRequest="false" /> I pass SQL around to pages, and sometimes, this causes the 'Cross Site
2
2068
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
9597
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
10618
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
10366
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
10371
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
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6877
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
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3850
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.