473,394 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

HttpRequestValidationException

We are using a custom guid generator with encryption, the problem is
sometimes pages will blow up when accessing this value through a post or
get. The encryption mechanism will sometimes generate the "bad" characters
to create this error. We would like to continue to leave validateRequest
turned on. What we would really like to be able to do is call the method
manually to catch an error before the user see's it and generate a new guid
for them that will pass when encrypted. I believe the method is private,
thus our dilema. Is there someway to get around this? Right now, we
generate the value, call a custom page to see if it fails, if so, then
generate a new value. This is way too much work....

Any help much appreciated,

jim butler
Nov 18 '05 #1
5 2890
Can you use Page_Error to trap the error and if it occurs and then call
whatever you need to do in the page?

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
----------------------------------
Making waves on the Web
"Jim Butler" <un**@companyabc.com> wrote in message
news:#D**************@TK2MSFTNGP09.phx.gbl...
We are using a custom guid generator with encryption, the problem is
sometimes pages will blow up when accessing this value through a post or
get. The encryption mechanism will sometimes generate the "bad" characters to create this error. We would like to continue to leave validateRequest
turned on. What we would really like to be able to do is call the method
manually to catch an error before the user see's it and generate a new guid for them that will pass when encrypted. I believe the method is private,
thus our dilema. Is there someway to get around this? Right now, we
generate the value, call a custom page to see if it fails, if so, then
generate a new value. This is way too much work....

Any help much appreciated,

jim butler

Nov 18 '05 #2
Hi Jim,

I think Rick's suggestion use the Page_Error event to handle the page level
unhandled exception and make the proper processing is reasonable, the
following article has discussing this topic:

#Rich Custom Error Handling with ASP.NET
http://msdn.microsoft.com/library/en...rs.asp?frame=t
rue

As for the @Page 's " ValidateRequest" attribute , as far as I know, this
is only configurable at design time in the @page directive rather than via
code. But we can manually perform the script validation ourself instead of
using the buildin validation. Here is a certain tech article discussing on
manually implement such validation in asp.net1.0 which haven't the buildin
"validateRequest" attribute:

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

Hope also helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

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

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3
thanks, steven, this is exactly what we were looking for but didn't find...
We will implement our own function that will check the generated encrypted
string while creating the string, if that makes any sense....

jim

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:Kb**************@cpmsftngxa10.phx.gbl...
Hi Jim,

I think Rick's suggestion use the Page_Error event to handle the page level unhandled exception and make the proper processing is reasonable, the
following article has discussing this topic:

#Rich Custom Error Handling with ASP.NET
http://msdn.microsoft.com/library/en...rs.asp?frame=t rue

As for the @Page 's " ValidateRequest" attribute , as far as I know, this
is only configurable at design time in the @page directive rather than via
code. But we can manually perform the script validation ourself instead of
using the buildin validation. Here is a certain tech article discussing on
manually implement such validation in asp.net1.0 which haven't the buildin
"validateRequest" attribute:

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

Hope also helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

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

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #4
There's no way to get the ValidateRequest behavior any other way though. The
chekcing for this occurs inside of the guts of ASP.Net, so there's little
you can do about changing the behavior other than capturing the exception.
I'm not sure I see the problem though because if you use Page_Error() you
get notified immediately if the erorr occurs at which point you can call
another method that does the right thing. Isn't this pretty much what you're
asking? Remember the failure will be the first thing that happens. You can
simply ignore it and call Page_Load manually for example to go on (Actually
I think you may have to force the page to manually render at that point but
that's still pretty straight forward.).

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
----------------------------------
Making waves on the Web
"Jim Butler" <un**@companyabc.com> wrote in message
news:#D**************@TK2MSFTNGP09.phx.gbl...
We are using a custom guid generator with encryption, the problem is
sometimes pages will blow up when accessing this value through a post or
get. The encryption mechanism will sometimes generate the "bad" characters to create this error. We would like to continue to leave validateRequest
turned on. What we would really like to be able to do is call the method
manually to catch an error before the user see's it and generate a new guid for them that will pass when encrypted. I believe the method is private,
thus our dilema. Is there someway to get around this? Right now, we
generate the value, call a custom page to see if it fails, if so, then
generate a new value. This is way too much work....

Any help much appreciated,

jim butler

Nov 18 '05 #5
I've created a page_error handler in a base usercontrol class to try
and trap the HttpRequestValidationException specifically for instances
of cross site scripting.

The handler works fine for example with Server.GetLastError and a
division by zero error in the page_load event of the child
usercontrol. However, I can't get this to work with
HttpRequestValidationException. Is this possible? I'm still slightly
baffled by the Request Validation feature.

Sorry no code as I'm out of the office but I'd be happy to accommodate
on monday.

Cheers,
Anant
Nov 18 '05 #6

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

Similar topics

13
by: R Reyes | last post by:
is there a way to avoid the validateRequest error page in my code behind file? i can't seem to find a way to handle the error w/o an error code or exception being thrown... i am NOT looking for...
1
by: Shail | last post by:
I receive this exception while debugging: System.Web.HttpRequestValidationException saying that A potentially dangerous Request.Form value was detected from the client (qtb="... #include...
6
by: Max Metral | last post by:
I use base64 to encode some cookie values. Today I got a "potentially dangerous cookie value" error. I've isolated it to anything matching this pattern: ..*On.*=.* in other words, anything...
1
by: bondzhou | last post by:
I have the following code in Page_Error handler subroutine: Exception ex =Server.GetLastError(); Response.Write(ex.Message); Response.Write(ex.StackTrace); Server.ClearError(); But it...
2
by: hn | last post by:
When a user enters a html tag <BR> in one of my textboxes, asp.net by default gives the error: "A potentially dangerous Request.Form value was detected from the client ....". I understand that...
6
by: Mark | last post by:
Hello, I'm trying to handle HttpRequestValidationException. If a hacker enters certain values into a textbox, like "<script>", it will trigger this error. I understand why .Net has this, but I...
4
by: Mike Dee | last post by:
Hi - I recently took my site live and I'm getting quite a lot of HttpRequestValidationException errors "A potentially dangerous Request.Form value...". I'm seeing quite a lot of these various...
5
by: lilOlMe | last post by:
I'm currently working on a project and would like my users to be able to enter anything they would like to enter; however, if they enter angled brackets "<" or ">" an HttpRequestValidationException...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.