Visual Studio中可以重新启动新的调试会话IIS防爆preSS?
我有执行的Application_Start在Global.asax中一些在数据库初始化的ASP.Net应用程序。我使用的是IIS防爆preSS调试应用程序。
I have an ASP.Net application that performs some database initialization during Application_Start in Global.asax. I'm using IIS Express to debug the application.
我觉得,如果我停止调试,清除数据库,并重新启动一次的的Application_Start code不会被调用,我的数据库没有正确初始化,所以我的应用程序失败。这是因为IIS防爆preSS实例调试停止后仍在运行。而不是重新启动它时,Visual Studio似乎附加到现有的工艺
I find that if I stop debugging, clear the database, and restart again, the Application_Start code does not get called and my database is not initialized properly, so my application fails. This is because the IIS Express instance is still running after debugging stops. Rather than restarting it, Visual Studio appears to be attaching to the existing process.
有没有办法来改变这种行为,从而开始一个新的调试会话始终重新启动IIS中前preSS应用程序(或定期重置IIS应用程序池)?
Is there a way to change this behavior such that starting a new debugging session always restarts the application process in IIS Express (or resets the application pool in regular IIS)?
另外,有没有办法强制IIS防爆preSS关闭时,调试会话结束?
Alternatively, is there a way to force IIS Express to shut down when the debugging session ends?
我发现,如果我选中启用编辑并继续从项目设置Web对话框,它有调试结束时停止IIS防爆preSS的副作用。但我不知道我要介绍编辑的副作用并继续只是停止IIS防爆preSS的目的。肯定有更好的办法?
I did find that if I check "Enable Edit and Continue" from the Web dialog in the project settings, that it has the side effect of stopping IIS Express when debugging ends. But I'm not sure I want to introduce the side-effects of Edit and Continue just for the purposes of stopping IIS Express. Surely there's a better way?
不知道是否它的问题,但是这是VS2012。
Not sure if it matters, but this is VS2012.
可惜这不是通过配置来实现的。我可以建议你一个绝招,但它是由你来决定它是否比你与否:)
Unfortunately it's not achievable through configuration. I may propose you another trick, but it's up to you to decide whether it's better than yours or not :)
您可以创建一个改变web.config文件的时间戳生成后事件。我使用 http://www.stevemiller.net/apps/ 一个touch.exe工具。您还需要设置运行后期生成事件的始终。所以,你的生成事件配置可能如下所示:
You may create a post-build event which changes the timestamp of a web.config file. I used a touch.exe tool from http://www.stevemiller.net/apps/. You also need to set the "Run the post-build event" to Always. So your "Build Events" configuration may look as follows:
此选项设置任何时候你启动调试器,web.config文件时间戳得到更新的第一个请求导致重新启动应用程序(应用程序域重新加载) - 但在这一点上,你已经连接到这个过程中让你的应用_
事件断点应该工作。
With this option set anytime you start the debugger, web.config timestamp is getting updated causing application restart (application appdomain reload) on the first request - but at this point you are already attached to this process so your Application_
event breakpoints should work.