Can Visual Studio restart IIS Express on new debugging session?

后端 未结 2 1700
北海茫月
北海茫月 2020-12-14 10:10

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.

I

相关标签:
2条回答
  • 2020-12-14 10:32

    You can use a Powershell one-liner to avoid relying on an external app:

    powershell -NoProfile -Command (Get-Item "<path>\Web.config").lastwritetime=(Get-Date)

    Original inspiration comes from here...

    0 讨论(0)
  • 2020-12-14 10:44

    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 :)

    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:

    enter image description here

    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.

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