Results 1 to 2 of 2

Thread: Problem Redirecting to the Custom Error Page

  1. #1

    Thread Starter
    Fanatic Member vuyiswamb's Avatar
    Join Date
    Jan 2007
    Location
    South Africa
    Posts
    830

    Problem Redirecting to the Custom Error Page

    Good Day ALL

    I have tried something and i am not sure what is the problem.

    i have inherited the an asp.net app. So i want to add the custom Error Handling. I know there are two methods i can do this.

    1) Web Config

    2)Global.asa

    So i started with the web config just to see how it will look and i accessed the page that normally gives an Exception. so basically i have a page gives a


    500 - Internal server error.
    There is a problem with the resource you are looking for, and it cannot be displayed.


    So now , if there is an Error i want it to go to that Error Page. In the web config i have the Following

    Code:
    <customErrors defaultRedirect="content/ErrorPages/SupportError.aspx" mode="On">
      <error statusCode="404" redirect="content/ErrorPages/SupportError.aspx" />
      <error statusCode="400" redirect="content/ErrorPages/SupportError.aspx" />
      <error statusCode="500" redirect="content/ErrorPages/SupportError.aspx" />
    </customErrors>
    This means that when this kind of Errors occur it should redirect to that page. All these pages are contents of the Master page including the Error page. But this Error Persist it does not show me the Error page. Even if i try to see if it goes to "Application_Error" in the Global.asa nothing goes there.

    So i have also tried the second option. so i turned the web config part
    "off" and i trapped this in the global.asa like this


    Code:
     Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
        Server.Transfer("~/Content/ErrorPages/SupportError.aspx")
     
        'Response.Redirect("~/Content/ErrorPages/SupportError.aspx", False)
    End Sub
    but still nothing happens

    THanks

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: Problem Redirecting to the Custom Error Page

    Hi if you use iis6 then the global.asax won't work that way.You will have to do a full handle on Application_BeginRequest thus your code will hit one every page postback and that will reduce performance.If you have iis7 and later you have better control but i haven't check it yet.
    Ok try this on your web.config:
    "~/content/ErrorPages/SupportError.aspx"
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

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