开发者

Application_error event not firing after publishing

开发者 https://www.devze.com 2023-03-22 07:26 出处:网络
I know this has been asked a lot of times, but I could not get things working from those posts. I have implemented Application_error method in Global.asax file to log and send email for all unhandled

I know this has been asked a lot of times, but I could not get things working from those posts.

I have implemented Application_error method in Global.asax file to log and send email for all unhandled exceptions. This works perfectly fine when running on Visual Studio, but as soon as I publish it to the test server, the Application_event stops firing. No log entry is made to the text file and no email is sent.

PrecompiledApp.config file is present in the root directory, along with App_global.asax.compiled, App_global.asax.dll in the 开发者_StackOverflowbin folder. Global.asax file is not present after I publish the website.

I have tried removing PrecompiledApp.config file, but it doesn't work. I have tried adding Global.asax file to the root directory, but doesn't work. I have tried with

   <customErrors mode="Off"  /> 

and

   <customErrors mode="On" defaultRedirect="Error Page.aspx" /> 

in web.config file....nothing works.

I added a line to Page_load of a page:

    Response.Write("<br/>ApplicationInstance: " +  Context.ApplicationInstance.GetType().FullName);

It returns ApplicationInstance: ASP.global_asax, which should be returned according to a post. Then why is the event not firing?

Please Help!!!

Thanks!!!

**[Edit] .... I added a line of code in Session_start event of Global.asax file and it worked. This means that Global.asax is getting deployed successfully. But why is Application_error event not getting executed in case of an error? Any ideas?


If the application encounter within the Application_error method, it will not throw it which make it look like the method is not being invoke.

I would check to make sure you have adequate exception handling within the application_error method.


Below code is working fine after publising to IIS.

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)

    If Context IsNot Nothing Then
        Context.ClearError()
        Response.Write("Application_Error" + "<br/><br/>")
        Response.Write("Error on Default Page")
    End If
End Sub
0

精彩评论

暂无评论...
验证码 换一张
取 消