What can cause Application_Error to be called?

In the last 2 weeks I have a case that I cannot understand, maybe you guys have already gone through the same problem or ear / read about it and can help me.

I have an ASP.NET project that I run on my machine and other machines perfectly, every time I try to moderate the QueryString, I get an error that is thrown by System.Exception

The problem is that in this particular machine (the witch is in Holland) Application_Error never catches the Exception, it saves the exception message to the log (as it does in my application) but it doesn't "break" the web application ... it just keeps going!

How and what can make this possible?


for example, this is my webpage (HttpCache cannot be called this way, but should only indicate that I am using a Web.HttpCache object)

if( Request.QueryString["user"] != HttpCache["MYAPP-user"] ) {
   myApp.DebugWrite("User was tempered.");
   throw System.Exception("User was tempered.");
}

      

and global.asax I have

...

void Application_Error(object sender, EventArgs e)
{
    // Code that runs when an unhandled error occurs
    if (Server.GetLastError() != null)
    {
        Exception objErr = Server.GetLastError().GetBaseException();
        String url = Request.Url.ToString();
        String msg = objErr.Message;
        String trc = objErr.StackTrace.ToString();


        Response.Clear();

        StringBuilder html = new StringBuilder();
        // fill up html with html code in order to present a nice message
        Response.Write(html.ToString()); 

        Server.ClearError();
        Response.Flush();
        Response.End();
    }
}

...

      


in my test machines, I always get html with an error message as well as a log message ... on this particular computer, I only see an error in the log, but the continue application !!!

web.config is exactly the same as on all machines and this web application runs on .NET 2.0

What could it be?

+2


source to share


1 answer


Comment out the Response and Server.ClearError () part in your code:



 //Response.Clear();

                StringBuilder html = new StringBuilder();
                // fill up html with html code in order to present a nice message
                Response.Write(html.ToString());

                //Server.ClearError();
                //Response.Flush();
                //Response.End();

      

-2


source







All Articles