Automatically stop/restart ASP.NET Development Server on Build Automatically stop/restart ASP.NET Development Server on Build asp.net asp.net

Automatically stop/restart ASP.NET Development Server on Build


Workaround: Debugging Global.aspx.cs Application_Start() with ASP.Net Web Server within Visual Studio

Enabling "Edit & Continue" on the web server project worked for me. It doesnt shutdown cassini when you stop debugging, but it does restart cassini when you start debugging.


So I ended up with a workaround based off Magnus' answer, but using the following relatively simple macro (why do they force you to use VB for macros? I feel all dirty):

Imports SystemImports System.DiagnosticsPublic Module KillCassini    Sub RestartDebug()        If (DTE.Debugger.DebuggedProcesses.Count > 0) Then            DTE.Debugger.Stop(True)        End If        KillCassini()        DTE.Debugger.Go(False)    End Sub    Sub KillCassini()        Dim name As String = "WebDev.WebServer"        Dim proc As Process        For Each proc In Process.GetProcesses            If (proc.ProcessName.StartsWith(name)) Then                proc.Kill()            End If        Next    End SubEnd Module

Basically if the debugger is currently running, it will stop it & then kill any processes named "WebDev.WebServer" which should be all the Cassini instances and then starts the debugger again (which will implicitly start Cassini again). I'm using proc.Kill() because neither proc.CloseMainWindow() or proc.WaitForExit(1000) seemed to work...

Anyway, once you've got your macro you can assign it to keyboard shortcuts, or create custom toolbar buttons to run it.


I just open a command line (runas admin)

run the following. It should kill all of them

Taskkill /IM WebDev.WebServer40.EXE /F