Home > Uncategorized > Visual Studio Built-in Web Server

Visual Studio Built-in Web Server

No doubt you’ve hit F5 to debug your web application from time to time, and you noticed the little web server that sits in your system tray.

In the old days you needed to have your web site setup as a virtual directory in IIS in order to be able to debug it. Now days it’s a lot easier: the first time you debug Visual Studio starts up its own mini-IIS that hosts your web application and lets you debug. This works for web sites, ASMX web services, and WCF services.

By default, it assigns a random port on the local machine. If you already have IIS then no doubt it is configured to use port 80, which is why the VS web server uses another random one. When your application loads up in browser, it will usually have a URL similar to this:

http://localhost:53669/default.aspx

Even when you stop debugging, the web server continues to run! Which means you can manually open a browser and still hit that same location. This is perfect if you don’t have a version of XP or Vista that comes with IIS.

However, by default the port number is random. This means tomorrow when you go to open and debug your application, it will run up with a different port number. Sometimes this is no big deal, but with web services and (in my case) WCF services, this hurts. Your WCF endpoints will be configured for debugging and the endpoints will specify the port number, so that you can debug them in VS. Every time the VS web server starts up, it gets a new random port number, which you then have to update in your WCF client endpoint.

Luckily the internal web server is configurable. With your web projects there is a property under the project properties – Web section:

By default, the "Use Visual Studio Development Server" option is checked, and "Auto-assign Port" is selected. However you can change this to "Specific Port" as I have in the above example. You can also configure the web server further to pretend to use a virtual directory. This is great because it allows you to simulate production environments by specifying the same combination of ports and virtual directories as would exist on the production server.

Of course, you can save yourself the hassle of having multiple web servers running at once by just selecting "Use IIS Web Server" instead, however this isn’t ideal in environments where multiple people work on a project and could potentially have different workstation setups.

Further Resources
ASP.NET and IIS Configuration
Build Web Server Solutions with End-To-End Extensibility
Web Servers in Visual Web Developer
Troubleshooting the ASP.NET Development Server

Categories: Uncategorized
  1. Unknown
    September 26, 2008 at 9:08 pm

    Hi,Do you need advertising displays, digital signages, ad players, advertisement player and LCD advertisings? Please go Here:www.amberdigital.com.hk(Amberdigital).we have explored and developed the international market with professionalism. We have built a widespread marketing network, and set up a capable management team dedicated to provide beyond-expectation services to our customers.
    amberdigital Contact Us
    website:www.amberdigital.com.hk
    alibaba:amberdigital.en.alibaba.com[bajjfcichghjhdg]

  2. Unknown
    October 23, 2008 at 5:36 pm

    Hi,Do you need digital signages, advertising displays, digital sign, advertisement displays and advertising players? Please go Here:www.amberdigital.com.hk(Amberdigital).we have explored and developed the international market with professionalism. We have built a widespread marketing network, and set up a capable management team dedicated to provide beyond-expectation services to our customers.
    amberdigital Contact Us
    website:www.amberdigital.com.hk
    alibaba:amberdigital.en.alibaba.com[gbggdjebiccfci]

  3. Unknown
    December 2, 2008 at 3:07 am

    I don\’t get it.  First off my project properties page looks nothing like that.  It It opens showing to windows one a single level tree with References, Build, Accessibility, Start Options and MSBuild Options.  Start Options includes everything shown on the page above except choice to auto assign ports, or not, and designation of the virtual path.  I have separate web services located as sub-directories of the root folder.  I can not configure them as applications like I do when using IIS.   I can\’t show the folder containing them as exluded from project.  I am reluctant to remove them from the directory physically because the real web site probably depends on them being in that location.  How can I set the bult-in web server to recognize these things as separate application?  I can not use IIS because we are not permitted to install that on our machines.

  4. Jeffrey
  1. No trackbacks yet.

Leave a comment