Why are the Global.asax events not firing in my ASP .NET website?

前端 未结 11 1930
执笔经年
执笔经年 2020-12-11 15:24

I\'ve been developing an ASP .NET 3.5 web application against Cassini, the built-in web development server, rather than against IIS.

In my Global.asax file, in the A

相关标签:
11条回答
  • 2020-12-11 15:48

    In your deployed enviroment, what is the thing you're calling? The reason I ask is because if you're calling a WCF based web service (ending in .svc), then Applicaiton_Start will not fire as the call to WCF isn't going through the ASP.NET pipeline. This wouldn't necessarily rear it's head w/ Cassini.

    0 讨论(0)
  • 2020-12-11 15:51

    I had a similar problem and I was wrestling with it for several days. The initial problem was something else - cookies not being set in Application's EndRequest handler. Finally I somehow managed to realize, that the problem actually was that the event is not being fired at all. It took some time to find that out, because all was working fine on my machine. But on the production server - quiet as a tomb.

    I am only writing this, because I really hope to save from troubles at least one person.

    The real reason for the problem was a missing global.asax file on the production server.

    The global.asax file was present on my computer, because the development environment is located there. I had prepared a deployment bat file, which coppies files from the development folder, removes the unnecessary ones and makes a package. Well - the global.asax file was marked for deletion in that script. After starting to deploy it all the problems went away.

    I hope I helped.

    0 讨论(0)
  • 2020-12-11 15:51

    also in IIS Manager turn on Dot Net debugging. It's under "Compilation"

    0 讨论(0)
  • 2020-12-11 15:52

    My fix was an odd one. On my development machine I am using localhost and I changed the port number it used - and then it worked.

    0 讨论(0)
  • 2020-12-11 15:57

    You may be getting a runtime exception that is occurring before your .NET code even gets a chance to run. If you look under the Event Viewer's Application logs, you may see some warnings or errors that will clue you in to what is happening.

    0 讨论(0)
  • 2020-12-11 15:58

    I thought I had a similar problem, working on some old projects, I was under the impression that the global.asax was not running because the code would first go into building my authentication controller which would fail because of class not registered (that part happens in the global.asax).

    Turned out it was due to a config item. When I moved the AuthenticationModule declaration into handler section in web config, it worked fine with IIS express.

    Basically, because of a config item, another piece of code was being executed before global.asax, making me believe that it would not be called.

    0 讨论(0)
提交回复
热议问题