Jul
7
2007

Starting ASP.NET Development Server from a right click in explorer

Update: Following the comment of Jon Galloway

I know that there are other solutions doing this but I was just asked about how to do it today (hey Christine ;) and had this registry file stored somewhere for a while waiting for a blog post.

Save this to a file with an extension .reg, e.g. "asp.net web server here.reg":

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\VS2005 WebServer]
@="ASP.NET 2.0 Web Server Here"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\VS2005 WebServer\command]
@="C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\Webdev.WebServer.exe /port:9081 /path:\"%1\""

You might also change the port used to start the ASP.NET Development Server. If this option is not specified then the port 80 is used.

Then double click on the .reg file to save the settings in the registry.

Now you will have access to the following right click menu in explorer and you can browse your site without running Visual Studio:

Update: This is not needed anymore

You will need to copy hstart.exe to your C:\Windows\system32\ first, or change the path used in the .reg file. This little tool (3kb); Hidden start, by NTWind Software is really good for "small startup manager that allows console applications to be started without any windows in the background.". Exactly what is need in our case.

Comments (8) -

I actually built a tool for this a while back. The problem with using this approach is that the port is always the same, meaning that it could potentially be guessable and hacked. My version installs an executable that wraps the ASP.NET web server to generate random port numbers on every launch.

You can find my app here: www.robertmclaws.com/.../entry5.aspx

Robert: The tool here is doesn't need any setup and the used tool is 3Kb so it is ok for me. The argument of hack is not relevant bfor me because I have a firewall that close the ports on my machine.

Cool!

I changed it to remove the HSTART dependency. I don't see any flicker at all, since it starts the server without launching a command window.

The port number is an optional parameter, so if you want dynamic ports you can just leave the "/port:9081" part out. It defaults to port 80, but if you've got IIS running then it'll find an unused port.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\VS2005 WebServer]
@="ASP.NET 2.0 Web Server Here"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\VS2005 WebServer\command]
@="C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\Webdev.WebServer.exe /port:9081 /path:%1"

http://

I didnt think the dev webserver would serve external requests.

Jesse: you are right it should not server something else than localhost

Jon: You are right the usage of hstart is not needed at all, but what you are saying about port 80 isn't true, it will not search for another port, it just says that the port is used.

And btw you are missing quotes around %1, in your case it would not work if there is a space in the path you try to run so the correct file content is

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\VS2005 WebServer]
@="ASP.NET 2.0 Web Server Here"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\VS2005 WebServer\command]
@="C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\Webdev.WebServer.exe /port:9081 /path:\"%1\""

http://

I couldn't get the ASP .NET development server running, but now with the reg key it's working.

Thanks for the help, it's much appreciated!

Eric

http://

The link above to Robert McLaws site does not work

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

About Laurent

Laurent Kempé

Laurent Kempé is the editor, founder, and primary contributor of Tech Head Brothers, a French portal about Microsoft .NET technologies.

He is currently employed by Innoveo Solutions since 10/2007 as a Senior Solution Architect and certified Scrum Master.

Founder, owner and Managing Partner of Jobping, which provides a unique and efficient platform for connecting Microsoft skilled job seekers with employers using Microsoft technologies.

Laurent is awarded by Microsoft since Avril 2002: Most Valuable Professional (MVP).

MVP
Certified ScrumMaster
JetBrains Academy Member

My status

Twitter

Flickr

www.flickr.com
This is a Flickr badge showing public photos and videos from Laurent Kempé. Make your own badge here.

Month List

Page List