Results 1 to 3 of 3

Thread: How to catch Httpexception

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    416

    How to catch Httpexception

    Hi,

    I have a simple aspx page contain a form to submit to server.
    When I open the page in IE and view the source, I see there is a VIEWSTATE hidden input with some value. I know it is the saved state of the control in my form.
    I save the code as HTML, and modify the VIEWSTATE value and re-submit the form to server, and I go the following error:

    [FormatException: Invalid character in a Base-64 string.]
    System.Convert.FromBase64String(String s) +0
    System.Web.UI.LosFormatter.Deserialize(String input) +25
    System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +102

    [HttpException (0x80004005): Invalid_Viewstate
    Client IP: 10.10.18.237
    Port: 3226
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)
    ViewState: avsdsgdfg;;;dDw2MTM1NjE........BmTEJ6Kxa+Lftpa0dNghkUUHc=
    Http-Referer:
    Path: /test/testpage.aspx.]
    System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +447
    System.Web.UI.Page.LoadPageViewState() +18
    System.Web.UI.Page.ProcessRequestMain() +447

    I would like to know, how can I catch such exception and re-direct user to a custom error page instead?

    Or, more general, is it possible to redirect user to a custom error page when there is an unhandled exception?

    Why I do so is because some hacker may intentionally modify the page in this way in order to discover extra system information, and I need to prevent this from happening.

    Thx a lot!

  2. #2
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: How to catch Httpexception

    Yes indeed you can have custom error pages by simply altering the web.config file. Take a look here and scroll down to Setting Custom Error Pages In web.config.

    HTH

    DJ

    If I have been helpful please rate my post. If I haven't tell me!

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    416

    Re: How to catch Httpexception

    Oh thx!
    I used Application_Error in global.asax to handle the exception and transfer user to a standard error page. Seems it works well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width