473,498 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to catch HttpRequestValidationException

hn
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 I can turn this error off by setting validateRequest=false
in the Page directive. However, I want to turn this property on and catch the
error using try and catch, but that didn't work. Is there a way to catch it
so that I can show the error in a more user friendly way. Thanks.
Nov 19 '05 #1
2 2450
Hi,

How about wiring a handler to Page.Error event?

Error += new EventHandler (this.Page_Error);

/Ivan Belov/

"hn" <hn@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
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 I can turn this error off by setting
validateRequest=false
in the Page directive. However, I want to turn this property on and catch
the
error using try and catch, but that didn't work. Is there a way to catch
it
so that I can show the error in a more user friendly way. Thanks.

Nov 19 '05 #2
hn
Hi Ivan,

I'll give it a try. Thanks for replying.

"Ivan Belov" wrote:
Hi,

How about wiring a handler to Page.Error event?

Error += new EventHandler (this.Page_Error);

/Ivan Belov/

"hn" <hn@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
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 I can turn this error off by setting
validateRequest=false
in the Page directive. However, I want to turn this property on and catch
the
error using try and catch, but that didn't work. Is there a way to catch
it
so that I can show the error in a more user friendly way. Thanks.


Nov 19 '05 #3

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

Similar topics

10
30243
by: Gary.Hu | last post by:
I was trying to catch the Arithmetic exception, unsuccessfully. try{ int a = 0, b = 9; b = b / a; }catch(...){ cout << "arithmetic exception was catched!" << endl; } After ran the program,...
11
3453
by: Pohihihi | last post by:
I was wondering what is the ill effect of using try catch in the code, both nested and simple big one. e.g. try { \\ whole app code goes here } catch (Exception ee) {}
23
3038
by: VB Programmer | last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the connection outside of the Try Catch Finally...
1
3877
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...
5
2892
by: Jim Butler | last post by:
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...
1
2231
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...
4
2021
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...
32
6082
by: cj | last post by:
Another wish of mine. I wish there was a way in the Try Catch structure to say if there wasn't an error to do something. Like an else statement. Try Catch Else Finally. Also because I...
5
5015
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
7125
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
7002
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
7165
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
7205
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...
1
6887
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...
0
7379
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...
0
3093
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...
0
1419
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 ...
0
291
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...

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.