errorPage attribute

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Paxxer
    New Member
    • Jan 2009
    • 22

    errorPage attribute

    Hi All,

    Code:
    <%@ Page Language="C#" 
             MasterPageFile="~/MasterPages/MyMaster.master"
             errorPage="~/Errors/Error.aspx"
             Title="This will have an Error"
             AutoEventWireup="true"
             CodeFile="NewError.aspx.cs"
             Inherits="NewError" %>
    When I throw an error the server does not redirect over to Error.aspx.

    Instead it gives me the unhandled error message that I see even without the errorPage directive.

    Any Ideas
    Thanks
    Tom
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Is this overridden by what is in your web.config error handling?

    Comment

    • Paxxer
      New Member
      • Jan 2009
      • 22

      #3
      Hi Kenobewan,

      I don't understand what you mean by "overridden ", I would expect the Parameter collection to throw an error according to the Link in my original post.

      If you mean, am I catching the error and then canceling it, no I am not. It doesn't seem to be raised in the first place.

      Comment

      • kenobewan
        Recognized Expert Specialist
        • Dec 2006
        • 4871

        #4
        Do you have any error handling code in your web.config?

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          Kenobewan's asking if you have set up custom errors in your web.config file.

          For example, if you place the following in your web.config in the <system.web> section, your application will redirect the user to the "~/Errors/Error.aspx" page:
          Code:
          <customErrors mode="RemoteOnly" defaultRedirect="~/Errors/Error.aspx">
          </customErrors>

          Comment

          • Paxxer
            New Member
            • Jan 2009
            • 22

            #6
            Thanks all.

            I've tried several configurations of error handling in the config file. It behaves as you would expect and will route error handling to the appropriate page. However, I would expect the errorPage attribute to overide the config setting, but it doesn't.

            Comment

            • Frinavale
              Recognized Expert Expert
              • Oct 2006
              • 9749

              #7
              Thinking about your problem I think I know what's going on.

              You would think that because the exception would be caught within the page error, that the redirect would be executed before the exception is bubbled up to the application level which is handled by the web.config.

              But apparently this isn't happening.
              I think that it's because you aren't actually trapping the exception and dealing with it.
              Instead it's left to bubble up to the application level which handles the exception for you before the page can be sent to the browser.

              What you probably should do is implement a method that handles the Page Error event instead of (or maybe along with) using the ErrorPage property. In this event, you can handle the error and redirect the user to the page you desire and this should prevent.

              -Frinny

              Comment

              • Paxxer
                New Member
                • Jan 2009
                • 22

                #8
                Hmm..

                What if I restate the question.

                errorPage="~/Errors/ItNeverGoesHere .aspx"

                What setting in the config file should I make, and where can I raise an error, where would I clear the error to expect to see the page
                "ItNeverGoesHer e.aspx"

                Comment

                • Frinavale
                  Recognized Expert Expert
                  • Oct 2006
                  • 9749

                  #9
                  I'm really not familiar with the ErrorPage property.

                  Try something for me, leave your errorPage="~/Errors/ItNeverGoesHere .aspx" and add a method that handles the Error event for the page. See if it goes to the "ItNeverGoesHer e.aspx" page.

                  If this doesn't work, try clearing the error from the server using the Server.ClearErr or() in the Error event for the page....

                  I don't know how to implement it in such a way that it gets to the "ItNeverGoesHer e.aspx" page using the ErrorPage property because I've never used this property.

                  I'm interested in knowing if this works...

                  Comment

                  Working...