473,796 Members | 2,570 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to compromise on ValidateRequest ?

AFN
I have a form with 15 fields. I want users to be able to enter "<" and ">"
characters into 1 of those fields without IIS catching it and disallowing
the whole page. I did some reading and I *think* that means I MUST set
ValidateRequest =False. So, two questions:

1) Do I have to then pass the results of every one of those 15 fields into
HtmlEncode? like strAfter = HtmlEncode(txtF ield1.text)? That's annoying
when I only want to allow 1 field to have the "<" ">" values.

2) What does the < character turn into when you do HtmlEncode? Generally.
I don't want it to turn into something like %20. If that is what it does,
then what other function can I use to test that my input is safe but still
keep it as < or >?
Nov 18 '05 #1
2 1393
Yes you must set ValidateRequest =False to disable .net framework to check
for "<" and ">" symbols.
also there is a bug in the VlidateRequest that enables to write in the form
fields "<%00"
so the answers :
1 ) You have to htmlencode all the fields that you will show on the page (
it is recommended to htmlecode all of data )
2 ) character "<" is turn into &lt; and character ">" - to &gt;

to do this i whould suggest you to create an CustomValidator controls for
every 14 fields BUT these 14 validators will use one function to check and
htmlecode the data

Hope this helps
Regards
Martin

"AFN" <DE************ ************@ya hoo.com> wrote in message
news:F5******** ********@twiste r.socal.rr.com. ..
I have a form with 15 fields. I want users to be able to enter "<" and ">" characters into 1 of those fields without IIS catching it and disallowing
the whole page. I did some reading and I *think* that means I MUST set
ValidateRequest =False. So, two questions:

1) Do I have to then pass the results of every one of those 15 fields into
HtmlEncode? like strAfter = HtmlEncode(txtF ield1.text)? That's annoying
when I only want to allow 1 field to have the "<" ">" values.

2) What does the < character turn into when you do HtmlEncode? Generally.
I don't want it to turn into something like %20. If that is what it does, then what other function can I use to test that my input is safe but still
keep it as < or >?

Nov 18 '05 #2
ValidateRequest =False is to prevent a common coding error. take the common
welcome message

John, welcome to my site

if implement as

<%= UserName %>, welcome to my site

you page is open to a scripting hack. the user when they enter their name
can input <script>....</script>. the fix is when output a user input data as
html is to encode it when rendered.

<%= HttpUtility.Htm lEncode(UserNam e) %>, welcome to my site

is complely safe. this is more of a problem when user enter data that is
displayed on other peoples pages, then the script can do more damage.

note: as any user can run arbitrary javascript on your page thru the
address bar, you should design your page to not trust postback values
(especially hidden fields)

-- bruce (sqlwork.com)


"AFN" <DE************ ************@ya hoo.com> wrote in message
news:F5******** ********@twiste r.socal.rr.com. ..
I have a form with 15 fields. I want users to be able to enter "<" and ">" characters into 1 of those fields without IIS catching it and disallowing
the whole page. I did some reading and I *think* that means I MUST set
ValidateRequest =False. So, two questions:

1) Do I have to then pass the results of every one of those 15 fields into
HtmlEncode? like strAfter = HtmlEncode(txtF ield1.text)? That's annoying
when I only want to allow 1 field to have the "<" ">" values.

2) What does the < character turn into when you do HtmlEncode? Generally.
I don't want it to turn into something like %20. If that is what it does, then what other function can I use to test that my input is safe but still
keep it as < or >?

Nov 18 '05 #3

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

Similar topics

1
3237
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.
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"...
8
1868
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
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
9684
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
10459
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...
1
10182
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
10017
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
9055
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
6793
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
5445
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
5577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.