Re: How to handle "A potentially dangerous Request.Form value wasdetected from the client"

Discussion in 'ASP .Net' started by Larry Bud, Jan 6, 2009.

  1. Larry Bud

    Larry Bud Guest

    On Dec 29 2008, 7:49 pm, Alan Silver <alan-
    > wrote:
    > Hello,
    >
    > I know why the "A potentially dangerous Request.Form value was detected
    > from the client" error happens, and I know it can be avoided by setting
    > validateRequest to false, but is there a way of handling the error
    > rather than disabling it?
    >
    > I have a form where I don't want people to be able to enter HTML, but I
    > don't want to show this ugly error if they do. I would like to be able
    > to catch the error and handle it myself by encoding the user's input,
    > rendering the HTML harmless.
    >
    > Any ideas? Thanks,
    > Alan
    >
    > --
    > Alan Silver
    > (anything added below this line is nothing to do with me)


    You can handle it in the page. Override the OnError sub

    Protected Overrides Sub OnError(ByVal e As System.EventArgs)
    'handle the error here. You may want to check the error msg because
    this will trap all errors.
    context.clearerror()

    End Sub
     
    Larry Bud, Jan 6, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jay B. Harlow [MVP - Outlook]

    Re: FileDialog window handle

    Jay B. Harlow [MVP - Outlook], Sep 2, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    3,922
    Mick Doherty
    Sep 3, 2003
  2. Dietrich
    Replies:
    1
    Views:
    656
    Joe Smith
    Jul 22, 2004
  3. Leon
    Replies:
    2
    Views:
    547
  4. =?ISO-8859-1?Q?KLEIN_St=E9phane?=
    Replies:
    3
    Views:
    461
    hanumizzle
    Oct 6, 2006
  5. ZRat
    Replies:
    0
    Views:
    511
Loading...

Share This Page