ASP.NET Development Server From ‘Here’ in PowerShell
Long title… almost longer than the code.
I used to have an old registry setting that started up the ASP.NET Development Server from the current path; however, since I rarely open up Explorer—and then opening up FireFox was even more painful—I needed a script.
What does it do?
The script starts up the ASP.NET Development server with a random port (so you can run multiples…) at your current location. It then activates your machine’s DEFAULT BROWSER and browses to the site. FireFox user? No problem. Works like a champ!
The Script (Full Code)
$path = resolve-path .
$rand = New-Object system.random
$port = $rand.next(2048,10240)
$path_to_devserver = “C:\\Program Files (x86)\\Common Files\\microsoft shared\\DevServer\\9.0\\Webdev.WebServer.exe”
& $path_to_devserver /port:$port /path:$path
(new-object -com shell.application).ShellExecute(“http:\\localhost:$port”)
The $path_to_devserver can be updated—depending on 64–bit vs. 32–bit machines. Simple, easy, and to the point. Now, no more fumbling around to launch a quick web application!