예제 #1
0
 internal TemplatedMailCompileErrorFormatter(HttpCompileException e, int eventsRemaining, bool showDetails) : base(e)
 {
     this._eventsRemaining            = eventsRemaining;
     this._showDetails                = showDetails;
     base._hideDetailedCompilerOutput = true;
     base._dontShowVersion            = true;
 }
 private void CacheCompileErrors(AssemblyBuilder assemblyBuilder, CompilerResults results)
 {
     System.Web.Compilation.BuildProvider provider = null;
     foreach (CompilerError error in results.Errors)
     {
         if (!error.IsWarning)
         {
             System.Web.Compilation.BuildProvider buildProviderFromLinePragma = assemblyBuilder.GetBuildProviderFromLinePragma(error.FileName);
             if (((buildProviderFromLinePragma != null) && (buildProviderFromLinePragma is BaseTemplateBuildProvider)) && (buildProviderFromLinePragma != provider))
             {
                 provider = buildProviderFromLinePragma;
                 CompilerResults results2 = new CompilerResults(null);
                 foreach (string str in results.Output)
                 {
                     results2.Output.Add(str);
                 }
                 results2.PathToAssembly            = results.PathToAssembly;
                 results2.NativeCompilerReturnValue = results.NativeCompilerReturnValue;
                 results2.Errors.Add(error);
                 HttpCompileException compileException = new HttpCompileException(results2, assemblyBuilder.GetGeneratedSourceFromBuildProvider(buildProviderFromLinePragma));
                 BuildResult          result           = new BuildResultCompileError(buildProviderFromLinePragma.VirtualPathObject, compileException);
                 buildProviderFromLinePragma.SetBuildResultDependencies(result);
                 BuildManager.CacheVPathBuildResult(buildProviderFromLinePragma.VirtualPathObject, result, this._utcStart);
             }
         }
     }
 }
        private void EmbedSourceCodeInformation(HttpCompileException ex)
        {
            var compilationErrors = ex.Results.Errors;

            if (!compilationErrors.HasErrors)
            {
                return;
            }

            CompilerError firstError = null;

            for (int i = 0; i < compilationErrors.Count; i++)
            {
                if (!compilationErrors[i].IsWarning)
                {
                    firstError = compilationErrors[i];
                    break;
                }
            }

            Verify.IsNotNull(firstError, "Failed to finding an error in the compiler results.");

            // Not showing source code of not related files
            if (!firstError.FileName.StartsWith(PathUtil.Resolve(VirtualPath), StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            string[] sourceCode = C1File.ReadAllLines(firstError.FileName);

            XhtmlErrorFormatter.EmbedSourceCodeInformation(ex, sourceCode, firstError.Line);
        }
예제 #4
0
        /// <summary>
        /// WebPages stores the version to be compiled against in AppSettings as &gt;add key="webpages:version" value="1.0" /&lt;.
        /// Changing values AppSettings does not cause recompilation therefore we could run into a state where we have files compiled against v1 but the application is
        /// currently v2.
        /// </summary>
        private static void InvalidateCompilationResultsIfVersionChanged(
            IBuildManager buildManager,
            IFileSystem fileSystem,
            string binDirectory,
            Version currentVersion
            )
        {
            Version previousVersion = WebPagesDeployment.GetPreviousRuntimeVersion(buildManager);

            // Persist the current version number in BuildManager's cached file
            WebPagesDeployment.PersistRuntimeVersion(buildManager, currentVersion);

            if (previousVersion == null)
            {
                // Do nothing.
            }
            else if (previousVersion != currentVersion)
            {
                // If the previous runtime version is different, perturb the bin directory so that it forces recompilation.
                WebPagesDeployment.ForceRecompile(fileSystem, binDirectory);
                var httpCompileException = new HttpCompileException(
                    ConfigurationResources.WebPagesVersionChanges
                    );
                // Indicator for tooling
                httpCompileException.Data[ToolingIndicatorKey] = true;
                throw httpCompileException;
            }
        }
        public static void Application_OnError()
        {
            HttpServerUtility Server = HttpContext.Current.Server;
            Exception         ex     = Server.GetLastError();

            if (ex != null)
            {
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                string        sException = ex.GetType().Name;
                StringBuilder sbMessage  = new StringBuilder();
                sbMessage.Append(ex.Message);
                // 03/10/2006 Paul.  .NET 2.0 returns lowercase type names. Use typeof instead.
                if (ex.GetType() == typeof(FileNotFoundException))
                {
                    // We can get this error for forbidden files such as web.config and global.asa.
                    //return ; // Return would work if 404 entry was made in web.config.
                    //Response.Redirect("~/Home/FileNotFound.aspx?aspxerrorpath=" + Server.UrlEncode(Request.Path));
                    sbMessage = new StringBuilder("File Not Found");
                }
                // 03/10/2006 Paul.  .NET 2.0 returns lowercase type names. Use typeof instead.
                else if (ex.GetType() == typeof(HttpException))
                {
                    HttpException exHttp    = (HttpException)ex;
                    int           nHttpCode = exHttp.GetHttpCode();
                    if (nHttpCode == 403)
                    {
                        //return ; // Return would work if 403 entry was made in web.config.
                        //Response.Redirect("~/Home/AccessDenied.aspx?aspxerrorpath=" + Server.UrlEncode(Request.Path));
                        sbMessage = new StringBuilder("Access Denied");
                    }
                    else if (nHttpCode == 404)
                    {
                        //return ; // Return would work if 404 entry was made in web.config.
                        //Response.Redirect("~/Home/FileNotFound.aspx?aspxerrorpath=" + Server.UrlEncode(Request.Path));
                        sbMessage = new StringBuilder("File Not Found");
                    }
                }
                // 03/10/2006 Paul.  .NET 2.0 returns lowercase type names. Use typeof instead.
                else if (ex.GetType() == typeof(HttpCompileException))
                {
                    HttpCompileException    exCompile = (HttpCompileException)ex;
                    CompilerErrorCollection col       = exCompile.Results.Errors;
                    foreach (CompilerError err in col)
                    {
                        sbMessage.Append("  ");
                        sbMessage.Append(err.ErrorText);
                    }
                }
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), sbMessage.ToString());
                Server.ClearError();
                string sQueryString = String.Format("aspxerrorpath={0}&Exception={1}&Message={2}", Server.UrlEncode(HttpContext.Current.Request.Path), sException, Server.UrlEncode(sbMessage.ToString()));
                HttpContext.Current.Response.Redirect("~/Home/ServerError.aspx?" + sQueryString);
            }
        }
예제 #6
0
        public static bool HandleHttpCompileException(HttpCompileException ex, bool clearError, HttpContext context, RouteData routeData, BaseController controller)
        {
            string rawUrl = context.Request.RawUrl;
            string url    = context.Request.Url.ToString();

            if (Settings.AppLogSystemEventsToDb || Settings.AppLogSystemEventsToFile)
            {
                LogHttpCompileException(ex, context, routeData, controller);
            }
            if (Settings.AppUseFriendlyErrorPages)
            {
                ShowErrorPage(ErrorPage.Error_HttpError, ex.GetHttpCode(), ex, clearError, context, controller);
                return(true);
            }
            return(false);
        }
예제 #7
0
        private static void LogHttpCompileException(HttpCompileException ex, HttpContext context, RouteData routeData, BaseController controller)
        {
            int    httpCode = ex.GetHttpCode();
            string message  = string.Empty;

            message = "Http Compile Exception " + httpCode + " " + ex.GetHtmlErrorMessage()
                      + "  \n-Message: " + ex.Message
                      + "  \n-Source: " + ex.Source
                      + "  \n-SourceCode: " + ex.SourceCode
                      + "  \n-FileName: " + ex.Results.Errors.ToString()
                      + "  \n-Compile Error Count: " + ex.Results.Errors.Count
                      + "  \n-Compile Errors: " + ex.Results.Errors.ToString()
                      + "  \n-WebEventCode: " + ex.WebEventCode
                      + "  \n-ErrorCode: " + ex.ErrorCode
                      + "  \n-TargetSiteName: " + ex.TargetSite.Name
                      + "  \n-StackTrace: " + ex.StackTrace;

            LogException(message, ex, Models.SystemEventLevel.Error, context, routeData, controller);
        }
예제 #8
0
        static void DumpErrors(Exception exception)
        {
            // Check if one of the inner exceptions is more appropriate
            Exception e2 = GetFormattableException(exception);

            if (e2 != null)
            {
                exception = e2;
            }

            if (exception is HttpCompileException)
            {
                // NOTE: These are now handled by the callback
#if OLD
                HttpCompileException e = (HttpCompileException)exception;
                DumpCompileErrors(e.Results);
#endif
            }
            else if (exception is HttpParseException)
            {
                // NOTE: These are now handled by the callback
#if OLD
                HttpParseException e = (HttpParseException)exception;
                DumpMultiParserErrors(e);
#endif
            }
            else
            if (exception is ConfigurationException)
            {
                ConfigurationException e = (ConfigurationException)exception;
                DumpError(e.Filename, e.Line, false, "ASPCONFIG", e.BareMessage);
            }
            else
            {
                DumpError(null, 0, false, "ASPRUNTIME", exception.Message);
            }

            if (_showErrorStack)
            {
                DumpExceptionStack(exception);
            }
        }
예제 #9
0
        protected virtual void ExceptionHandler(ExceptionContext filterContext)
        {
            if (!filterContext.ExceptionHandled)
            {
                if (filterContext.Exception.GetBaseException() is DynamicPageInactiveException)
                {
                    DynamicPageInactiveException exDPI = filterContext.Exception.GetBaseException() as DynamicPageInactiveException;
                    filterContext.ExceptionHandled = Exceptions.ExceptionHandler.HandleDynamicPageInactiveException(exDPI, false, filterContext.HttpContext.ApplicationInstance.Context, RouteData, this);
                    return;
                }
                else if (filterContext.Exception.GetBaseException() is DynamicPageNotFoundException)
                {
                    DynamicPageNotFoundException exDPNF = filterContext.Exception.GetBaseException() as DynamicPageNotFoundException;
                    filterContext.ExceptionHandled = Exceptions.ExceptionHandler.HandleDynamicPageNotFoundException(exDPNF, false, filterContext.HttpContext.ApplicationInstance.Context, RouteData, this);
                    return;
                }
                else if (filterContext.Exception.GetBaseException() is NoMatchingBindingException)
                {
                    NoMatchingBindingException exNMB = filterContext.Exception.GetBaseException() as NoMatchingBindingException;
                    filterContext.ExceptionHandled = Exceptions.ExceptionHandler.HandleNoMatchingBindingException(exNMB, false, filterContext.HttpContext.ApplicationInstance.Context, RouteData, this);
                    return;
                }
                else if (filterContext.Exception.GetBaseException() is StoreFrontInactiveException)
                {
                    StoreFrontInactiveException exSFI = filterContext.Exception.GetBaseException() as StoreFrontInactiveException;
                    filterContext.ExceptionHandled = Exceptions.ExceptionHandler.HandleStoreFrontInactiveException(exSFI, false, filterContext.HttpContext.ApplicationInstance.Context, RouteData, this);
                    return;
                }
                else if (filterContext.Exception is HttpCompileException || filterContext.Exception.GetBaseException() is HttpCompileException)
                {
                    HttpCompileException httpCompileEx = null;
                    if (filterContext.Exception is HttpCompileException)
                    {
                        httpCompileEx = filterContext.Exception as HttpCompileException;
                    }
                    else
                    {
                        httpCompileEx = filterContext.Exception.GetBaseException() as HttpCompileException;
                    }
                    filterContext.ExceptionHandled = Exceptions.ExceptionHandler.HandleHttpCompileException(httpCompileEx, false, filterContext.HttpContext.ApplicationInstance.Context, RouteData, this);
                    return;
                }
                else if (filterContext.Exception is HttpParseException || filterContext.Exception.GetBaseException() is HttpParseException)
                {
                    HttpParseException httpParseEx = null;
                    if (filterContext.Exception is HttpCompileException)
                    {
                        httpParseEx = filterContext.Exception as HttpParseException;
                    }
                    else
                    {
                        httpParseEx = filterContext.Exception.GetBaseException() as HttpParseException;
                    }
                    filterContext.ExceptionHandled = Exceptions.ExceptionHandler.HandleHttpParseException(httpParseEx, false, filterContext.HttpContext.ApplicationInstance.Context, RouteData, this);
                    return;
                }
                else if (filterContext.Exception is HttpException || filterContext.Exception.GetBaseException() is HttpException)
                {
                    HttpException httpEx = null;
                    if (filterContext.Exception is HttpException)
                    {
                        httpEx = filterContext.Exception as HttpException;
                    }
                    else
                    {
                        httpEx = filterContext.Exception.GetBaseException() as HttpException;
                    }
                    filterContext.ExceptionHandled = Exceptions.ExceptionHandler.HandleHttpException(httpEx, false, filterContext.HttpContext.ApplicationInstance.Context, RouteData, this);
                    return;
                }
                else if (filterContext.Exception is ApplicationException)
                {
                    ApplicationException appEx = filterContext.Exception as ApplicationException;
                    filterContext.ExceptionHandled = Exceptions.ExceptionHandler.HandleAppException(appEx, false, filterContext.HttpContext.ApplicationInstance.Context, RouteData, this);
                    return;
                }
                else if (filterContext.Exception is InvalidOperationException || filterContext.Exception.GetBaseException() is InvalidOperationException)
                {
                    InvalidOperationException ioEx = null;
                    if (filterContext.Exception is InvalidOperationException)
                    {
                        ioEx = filterContext.Exception as InvalidOperationException;
                    }
                    else
                    {
                        ioEx = filterContext.Exception.GetBaseException() as InvalidOperationException;
                    }
                    filterContext.ExceptionHandled = Exceptions.ExceptionHandler.HandleInvalidOperationException(ioEx, false, filterContext.HttpContext.ApplicationInstance.Context, RouteData, this);
                    return;
                }

                //Unknown exception handler
                //exceptions that are expected or common should hit the above exception handlers.
                Exception ex = filterContext.Exception;
                filterContext.ExceptionHandled = Exceptions.ExceptionHandler.HandleUnknownException(ex, false, filterContext.HttpContext.ApplicationInstance.Context, RouteData, this);
                return;
            }
        }
예제 #10
0
        // Cache the various compile errors found during batching
        private void CacheCompileErrors(AssemblyBuilder assemblyBuilder, CompilerResults results)
        {
            BuildProvider previous = null;

            // Go through all the compile errors
            foreach (CompilerError error in results.Errors)
            {
                // Skip warnings
                if (error.IsWarning)
                {
                    continue;
                }

                // Try to map the error back to a BuildProvider.  If we can't, skip the error.
                BuildProvider buildProvider = assemblyBuilder.GetBuildProviderFromLinePragma(error.FileName);
                if (buildProvider == null)
                {
                    continue;
                }

                // Only cache the error for template controls.  Otherwise, for file types like
                // asmx/ashx, it's too likely that two of them define the same class.
                if (!(buildProvider is BaseTemplateBuildProvider))
                {
                    continue;
                }

                // If the error is for the same page as the previous one, ignore it
                if (buildProvider == previous)
                {
                    continue;
                }
                previous = buildProvider;

                // Create a new CompilerResults for this error
                CompilerResults newResults = new CompilerResults(null /*tempFiles*/);

                // Copy all the output to the new result.  Note that this will include all the
                // error lines, not just the ones for this BuildProvider.  But that's not a big deal,
                // and we can't easily filter the output here.
                foreach (string s in results.Output)
                {
                    newResults.Output.Add(s);
                }

                // Copy various other fields to the new CompilerResults object
                newResults.PathToAssembly            = results.PathToAssembly;
                newResults.NativeCompilerReturnValue = results.NativeCompilerReturnValue;

                // Add this error.  It will be the only one in the CompilerResults object.
                newResults.Errors.Add(error);

                // Create a new HttpCompileException & BuildResultCompileError to wrap this error
                HttpCompileException e = new HttpCompileException(newResults,
                                                                  assemblyBuilder.GetGeneratedSourceFromBuildProvider(buildProvider));
                BuildResult result = new BuildResultCompileError(buildProvider.VirtualPathObject, e);

                // Add the dependencies to the compile error build provider, so that
                // we will retry compilation when a dependency changes
                buildProvider.SetBuildResultDependencies(result);

                // Cache it
                BuildManager.CacheVPathBuildResult(buildProvider.VirtualPathObject, result, _utcStart);
            }
        }
예제 #11
0
        public void Constructor2a_Deny_Unrestricted()
        {
            HttpCompileException e = new HttpCompileException(new CompilerResults(null), "source");

            Assert.IsNotNull(e.Message, "Message");
        }
예제 #12
0
 internal BuildResultCompileError(VirtualPath virtualPath, HttpCompileException compileException) {
     VirtualPath = virtualPath;
     _compileException = compileException;
 }
        /// <summary>
        /// WebPages stores the version to be compiled against in AppSettings as &gt;add key="webpages:version" value="1.0" /&lt;. 
        /// Changing values AppSettings does not cause recompilation therefore we could run into a state where we have files compiled against v1 but the application is 
        /// currently v2.
        /// </summary>
        private static void InvalidateCompilationResultsIfVersionChanged(IBuildManager buildManager, IFileSystem fileSystem, string binDirectory, Version currentVersion)
        {
            Version previousVersion = WebPagesDeployment.GetPreviousRuntimeVersion(buildManager);

            // Persist the current version number in BuildManager's cached file
            WebPagesDeployment.PersistRuntimeVersion(buildManager, currentVersion);

            if (previousVersion == null)
            {
                // Do nothing.
            }
            else if (previousVersion != currentVersion)
            {
                // If the previous runtime version is different, perturb the bin directory so that it forces recompilation.
                WebPagesDeployment.ForceRecompile(fileSystem, binDirectory);
                var httpCompileException = new HttpCompileException(ConfigurationResources.WebPagesVersionChanges);
                // Indicator for tooling
                httpCompileException.Data[ToolingIndicatorKey] = true;
                throw httpCompileException;
            }
        }
        internal MobileErrorInfo(Exception e)
        {
            // Don't want any failure to escape here...
            try
            {
                // For some reason, the compile exception lives in the
                // InnerException.
                HttpCompileException compileException =
                    e.InnerException as HttpCompileException;

                if (compileException != null)
                {
                    this.Type        = SR.GetString(SR.MobileErrorInfo_CompilationErrorType);
                    this.Description = SR.GetString(SR.MobileErrorInfo_CompilationErrorDescription);
                    this.MiscTitle   = SR.GetString(SR.MobileErrorInfo_CompilationErrorMiscTitle);

                    CompilerErrorCollection errors = compileException.Results.Errors;

                    if (errors != null && errors.Count >= 1)
                    {
                        CompilerError error = errors[0];
                        this.LineNumber = error.Line.ToString(CultureInfo.InvariantCulture);
                        this.File       = error.FileName;
                        this.MiscText   = error.ErrorNumber + ":" + error.ErrorText;
                    }
                    else
                    {
                        this.LineNumber = SR.GetString(SR.MobileErrorInfo_Unknown);
                        this.File       = SR.GetString(SR.MobileErrorInfo_Unknown);
                        this.MiscText   = SR.GetString(SR.MobileErrorInfo_Unknown);
                    }

                    return;
                }

                HttpParseException parseException = e as HttpParseException;
                if (parseException != null)
                {
                    this.Type        = SR.GetString(SR.MobileErrorInfo_ParserErrorType);
                    this.Description = SR.GetString(SR.MobileErrorInfo_ParserErrorDescription);
                    this.MiscTitle   = SR.GetString(SR.MobileErrorInfo_ParserErrorMiscTitle);
                    this.LineNumber  = parseException.Line.ToString(CultureInfo.InvariantCulture);
                    this.File        = parseException.FileName;
                    this.MiscText    = parseException.Message;
                    return;
                }

                // We try to use the hacky way of parsing an HttpException of an
                // unknown subclass.
                HttpException httpException = e as HttpException;
                if (httpException != null && ParseHttpException(httpException))
                {
                    return;
                }
            }
            catch
            {
                // Don't need to do anything here, just continue to base case
                // below.
            }

            // Default to the most basic if none of the above succeed.
            this.Type        = e.GetType().FullName;
            this.Description = e.Message;
            this.MiscTitle   = SR.GetString(SR.MobileErrorInfo_SourceObject);
            String s = e.StackTrace;

            if (s != null)
            {
                int i = s.IndexOf('\r');
                if (i != -1)
                {
                    s = s.Substring(0, i);
                }
                this.MiscText = s;
            }
        }
예제 #15
0
 internal BuildResultCompileError(VirtualPath virtualPath, HttpCompileException compileException)
 {
     base.VirtualPath       = virtualPath;
     this._compileException = compileException;
 }
    // Cache the various compile errors found during batching
    private void CacheCompileErrors(AssemblyBuilder assemblyBuilder, CompilerResults results) {

        BuildProvider previous = null;

        // Go through all the compile errors
        foreach (CompilerError error in results.Errors) {

            // Skip warnings
            if (error.IsWarning)
                continue;

            // Try to map the error back to a BuildProvider.  If we can't, skip the error.
            BuildProvider buildProvider = assemblyBuilder.GetBuildProviderFromLinePragma(error.FileName);
            if (buildProvider == null)
                continue;

            // Only cache the error for template controls.  Otherwise, for file types like
            // asmx/ashx, it's too likely that two of them define the same class.
            if (!(buildProvider is BaseTemplateBuildProvider))
                continue;

            // If the error is for the same page as the previous one, ignore it
            if (buildProvider == previous)
                continue;
            previous = buildProvider;

            // Create a new CompilerResults for this error
            CompilerResults newResults = new CompilerResults(null /*tempFiles*/);

            // Copy all the output to the new result.  Note that this will include all the
            // error lines, not just the ones for this BuildProvider.  But that's not a big deal,
            // and we can't easily filter the output here.
            foreach (string s in results.Output)
                newResults.Output.Add(s);

            // Copy various other fields to the new CompilerResults object
            newResults.PathToAssembly = results.PathToAssembly;
            newResults.NativeCompilerReturnValue = results.NativeCompilerReturnValue;

            // Add this error.  It will be the only one in the CompilerResults object.
            newResults.Errors.Add(error);

            // Create a new HttpCompileException & BuildResultCompileError to wrap this error
            HttpCompileException e = new HttpCompileException(newResults,
                assemblyBuilder.GetGeneratedSourceFromBuildProvider(buildProvider));
            BuildResult result = new BuildResultCompileError(buildProvider.VirtualPathObject, e);

            // Add the dependencies to the compile error build provider, so that
            // we will retry compilation when a dependency changes
            buildProvider.SetBuildResultDependencies(result);

            // Cache it
            BuildManager.CacheVPathBuildResult(buildProvider.VirtualPathObject, result, _utcStart);
        }

    }
예제 #17
0
 public void FixtureSetUp()
 {
     hce = new HttpCompileException();
 }
예제 #18
0
        //=======================================================================
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // If we're being requested by CompileAll.aspx then stop everything as we don't want to litter EventLog with errors.
            if (Page.Request.UrlReferrer != null &&
                StringUtil.EndsWithIgnoreCase(Page.Request.UrlReferrer.AbsolutePath, "CompileAll.aspx"))
            {
                Response.End();
            }

            // Don't present newly logged on user with an error page if they were given a dodgy initial URL
            bool referrerWasLoginPage = (Request.UrlReferrer != null && Request.UrlReferrer.Query.StartsWith("?ReturnUrl="));

            if (referrerWasLoginPage)
            {
                Response.Redirect("~/Main.aspx", true);
            }

            Response.ClearContent();
            Response.StatusCode = 500;

            // So that we don't Trace this actual Error page (we want to trace the page that caused the error)
            Trace.IsEnabled = false;

            // Pick up error (stored by Global.asax)
            Exception theError = (Exception)Context.Items["LastError"];

            // look for HttpCompileException
            HttpCompileException compileError = recurseForCompileError(theError);

            // Get the actual exception rather than the HttpUnhandledException "wrapper"
            if (theError is HttpUnhandledException)
            {
                theError = theError.InnerException;
            }

            if (compileError != null)
            {
                ErrorMessage = "Error in .ASPX code:\r\n";
                foreach (System.CodeDom.Compiler.CompilerError error in compileError.Results.Errors)
                {
                    ErrorMessage += error + "\r\n";
                }
            }
            else if (theError is UserException)
            {
                UserErrorMessage    = theError.Message;
                ErrorMessage        = theError.ToString();
                Response.StatusCode = 200; // This is not really an "error" in the code as far as we're concerned.
            }
            else if (theError is HttpException)
            {
                Response.StatusCode = ((HttpException)theError).GetHttpCode();
                ErrorMessage        = theError.ToString();
            }
            else
            {
                ErrorMessage = theError.ToString();
            }

            if (theError.InnerException != null && theError.InnerException is HttpException)
            {
                HttpException httpError = (HttpException)theError.InnerException;
                int           httpCode  = httpError.GetHttpCode();
                Response.StatusCode = httpCode;
                if (httpCode == 401) //access denied
                {
                    ClientAlert("Access denied: " + httpError.Message);
                }
            }


#if DEBUG
            if (Debugger.IsAttached)
            {
                Regex fileAndLine = new Regex(@"^.*at (?<method>.*) in (?<file>[\w\\:\.]+):line (?<line>[0-9]+).*$",
                                              RegexOptions.ExplicitCapture | RegexOptions.Multiline);


                Debugger.Log(9, Debugger.DefaultCategory, fileAndLine.Replace(ErrorMessage, "${file}(${line}):\n$0"));
                debugLabel.Visible = true;
            }
#endif

            // Remove some noise from stacktrace
            ErrorMessage = removeFilePathsFromStackTrace(ErrorMessage);

            // Write error to EventLog and email it
            LogAndEmailError(ErrorMessage);

            if (Global.DynamicTraceAllowed)
            {
                //loadTraceTableControl();
            }
            else
            {
                // Don't dump stack trace onto page
                ErrorMessage = "Extra error information in server Application EventLog (set IB.config DynamicTraceAllowed=True to display information).";

                // ...but don't hint at extra information in EventLog when there won't be
                if (theError is UserException)
                {
                    ErrorMessage = string.Empty;
                }
            }

            DataBind();
        }
예제 #19
0
        public void Constructor2b_Deny_Unrestricted()
        {
            HttpCompileException e = new HttpCompileException("message", new Exception());

            Assert.IsNotNull(e.Message, "Message");
        }
        internal TemplatedMailCompileErrorFormatter(HttpCompileException e, int eventsRemaining,
                                                                    bool showDetails) :
            base(e) {
            _eventsRemaining = eventsRemaining;
            _showDetails = showDetails;

            _hideDetailedCompilerOutput = true;
            _dontShowVersion = true;
        }