views:

133

answers:

1

Hi guys,

For the last 2 weeks I have a case that I can't figure it out, maybe you guys already passed 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 fine, every time I try to temper the QueryString I get an error that is been thrown by the System.Exception

problem is, in this particular machine (witch is in Holland) the Application_Error never catches the Exception, it saves the Exception message to the log (as in my application should be done) but it does not "break" the web application... it just continues!

How and what can make this possible?


for an example sake, this is my webpage (HttpCache canot be invoked like this, but is only to point that I'm using the Web.HttpCache object)

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

and in 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 the html with the error message, as well the message in the log... in this particular machine, I only see the error in the log, but the application continue!!!

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

What can it be?

A: 

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();
azamsharp
-1 don't know if you notest, but the Exception never get's to the Application_Error
balexandre
You should have just made a comment instead of -1. :(
azamsharp