Application_start event not firing in server, but works just fine in debug.

Anish Soman 20 Reputation points
2024-10-08T00:55:19.7766667+00:00

We have an .net framework web application running on IIS 10. I've added some code in the Application_start method of Global.asax.cs and it's not getting fired at all in the server. This is working just fine in debug using visual studio 2022 using target framework 4.6 Build machine is also using visual studio 2022, and the target framework in server is also 4.6. . It's not just Application_start and looks like no event in Global.asax.cs is being fired. We have some methods in Application_Error to capture the uncaught exception and to show a user friendly error message. That also is not working.

Interesting part is that this worked a few months ago. After that there were no changes to Global.asax or Global.asax.cs.

We can't debug on server since there is no Visual Studio installed there. Any guidance on what could be wrong or any way to identify the issue is appreciated.

Thanks in Advance.

Internet Information Services
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,547 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 68,486 Reputation points
    2024-10-08T17:12:45.1666667+00:00

    this is generally a permission error on the server. also check you deployed Global.asax and the code behind file is in the build.

    note: .net 4.6 is no longer supported. you should see if the issue is reproducible when the server is using .net 4.8


  2. Anish Soman 20 Reputation points
    2024-12-02T18:00:20.5766667+00:00

    The issue was due to a 'PrecompiledApp.config' file present in the deployment folder. This app was a 'WebSite' app previously and when we converted it to 'WebApplication', it looks like the devops pipeline missed to cleanup the PrecompiledApp.config. Deleted that file and everything is working now.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.