doubt with Exception handle in web pages.

Topics: ASP.NET Web Pages
Aug 6, 2014 at 2:49 AM
hi,
i`m reading the source code of web pages and confused with the exception handle in web pages. here are codes found in "System.Web.WebPages/WebPageHttpModule.cs":
internal static void InitApplication(HttpApplication application) {
            StartApplication(application);
            InitializeApplication(application);
        }
in StartApplication(), it will at last call the ExecuteStartPage() method which resides in "System.Web.WebPages/ApplicationStartPage.cs":
internal static void ExecuteStartPage(......) {
            try {
                ExecuteStartPageInternal(application, monitorFile, fileExists, createInstance, supportedExtensions);
            }
            catch (Exception e) {
                // Throw it as a HttpException so as to
                // display the original stack trace information.
                Exception = e;
                throw new HttpException(null, e);
            }
        }
hey, if we get an exception in ExecuteStartPage(), then we can not get the chance to call next line, the InitializeApplication() method, right?

so, the InitializeApplication() method:
internal static void InitializeApplication(......) {
            if (initialize != null) {
                initialize(application, EventArgs.Empty);
            }
            application.PostResolveRequestCache += onApplicationPostResolveRequestCache;
            if (ApplicationStartPage.Exception != null || BeginRequest != null) {
                application.BeginRequest += OnBeginRequest;
            }

            application.EndRequest += OnEndRequest;
        }
the 'ApplicationStartPage.Exception != null' seems worthless, well, at least for me.

am i misunderstood something here? what's the purpose to do like this?

thanks in advance.