5

I develop and debug an ASP.NET application with VS 2010. My ASP.NET application holds some connections to other applications on other machines. When I stop debugging, I want these connections to be released. If this doesn't happen, these other applications fail and I have to restart them.

In the end I will store my termination code in the Application_End method in Global.asax.cs, but this one is not called when stopping debugging.

Is there a way to terminate the debugging of my ASP.NET application so that not everything is killed at once, but so that one last method is called in which I could add my termination code?

Rob Lu
  • 115
  • 12
  • Isn't it better to make the calls establishing the connections to the other machines stable, so you don't have to restart the other apps? – PHeiberg Jan 10 '12 at 09:43
  • Post your code - how are you opening the connections? What do you mean by "connections to other applications on other machines" - how is this achieved? – Oded Jan 10 '12 at 09:44
  • Of course it would be better to make the connections (.Net Remoting) stable, but this is not possible at the moment, because I don't have access to the other applications' code. I can only restart them. – Rob Lu Jan 10 '12 at 16:37

2 Answers2

1

I'm not sure what your problem is but probably...

You initialize your debug session by pressing F5 and thus debugging through cassini. This way when you end your debug session the application is terminated.

If you have a configured IIS application you could simply attach to the running process - it's usually "CTRL + ALT + P" - choosing w3wp.exe (mind the checkboxes on the bottom to be checked). This way your app won't be terminated on ending the debugging session.

Does it solve your problem?

ub1k
  • 1,674
  • 10
  • 14
1

I misunderstood how debugging an ASP.NET application works. I thought the moment I stop debugging (by pressing Shift+F5) the ASP.NET application is terminated and no further line of code is executed. It was my explanation to why the Application_End method is not called.

But in fact the ASP.NET application goes on when the debugger is detached and therefore the Application_End method is not called.

Rob Lu
  • 115
  • 12