Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7431329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:16:43+00:00 2026-05-29T09:16:43+00:00

I have added try catches in my site which work great. The next part

  • 0

I have added try catches in my site which work great. The next part in development is to set up some exception handling output. Obviously I don’t want the site to crumble when an error occurs and I don’t want a horrible error screen. So, somewhere in the middle would be nice.
I was thinking to have an exception handler user control in the main master page which wil output a nice little message when something goes wrong.
What would be the best way to pass the exception to this user control? I was thinking of using a session variable.

Does anyone have a solution to this problem?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:16:44+00:00Added an answer on May 29, 2026 at 9:16 am

    This is easier than you’re making it. Create a page called error.aspx (or whatever you want to call it), and turn the CustomErrors on in the web.config.

    <configuration>
      <system.web>
        <customErrors defaultRedirect="errors.aspx"
                      mode="On">
        </customErrors>
      </system.web>
    </configuration>
    

    There is a lot of configurability to handle different http errors or random exceptions. If you want, you can dump the exception message (or the exception itself) into the session or use the HttpServerUtility.GetLastError (documentation)and then output any number of different messages on the error page. This will even catch exceptions that you DON’T catch.

    CustomErrors Documentation

    Edit:
    @Icarus indicates that OP is looking for a solution by which the page continues to render and output while only showing an error message within the page, so I’ll provide an answer to that as well.

    There are a few ways I’ve handled this in the past. For very complex pages where the behavior requested is fatal (the page result can’t be known), I’ve always deferred to an error page as I mentioned above that includes major master elements. So the menu, header, etc are all still there, but the notification of cataclysm is evident.

    The behavior you seem to be looking for is something I would use less out of a need to report exceptions than to report general messages. My preference is to have a user control that has a public bindable property that a message can be injected into. Such as (forgive the VB, I can’t seem to find my C# version):

    <BrowsableAttribute(True), Bindable(False), Category("Misc"), _
        Description("Gets or sets the NavigateUrl property for the link to start a new request.")> _
    Public Property MyImportantMessage() As String
        Get
            Return _myImportantMessage
        End Get
        Set(ByVal value As String)
            _myImportantMessage= value
        End Set
    End Property
    

    Then the output could be any string message you like or you could program in a number of presets, fetch from resources, whatever. As to how to get it in there, we have taken the MasterPage route. We have a method in our master pages which assigns such a property in the user control directly. In order for this method to be callable, each page that uses the master page has to include the VirtualPath property, otherwise the method will not be available at compile time.

    <%@ MasterType 
        VirtualPath="~/MasterPage.master" %>
    

    This then allows the Master property to be called from within the page itself to call this property:

    'Keeping the VB theme
    Me.Master.SetImportantMessage(message)
    

    Keep in mind that Me.Master from within the page is not the same as Page.Master. So your exception will either need to bubble up to the actual page or the page reference itself will have to be sent down to your usercontrols as a property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ill try my best to explain this.. in the site.master I have added a
i am having this problem try to use the cocos2d CCScrollLayer I have added
I have added a plugin called scrollpaper to a site I'm working on. The
I have added two modules in my drupal site called.... 1. me alias 2.
I am (slowly) making the switch to vim. I have added some settings to
I have a static canvas. I have added a shape runtime. Then I try
I try to use NUnit with SnippetCompiler http://www.sliver.com/dotnet/SnippetCompiler/ I have added references to nunit.framework.dll
I have added an index on a table just to ensure that a set
I have added usercontrol on a sharepoint 2007 site. When I add an item
I have added the library ksoap2-android-assembly-2.4-jar-with-dependencies.jar but i am getting below error : Exception

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.