in

Dot Net Mafia

Group site for developer blogs dealing with (usually) .NET, SharePoint 2013, SharePoint 2010, Office 365, SharePoint Online, and other Microsoft products, as well as some discussion of general programming related concepts.

This Blog

Syndication

Archives

Corey Roth [MVP]

A SharePoint MVP bringing you the latest time saving tips for SharePoint 2013, Office 365 / SharePoint Online and Visual Studio 2013.

How to run a root "/" site with the Local Web Server

As I have mentioned in the past, you are no longer required to set up IIS on your machine to run a web site.  There is a builtin web server that will run your site for you.  The problem with this is that it always runs the site in a sub folder.  This causes problems with a lot of sites because you may have references to controls, images, stylesheets, etc. using an absolute path (i.e.: /stylesheets/base.css).  You can either change all of your references to use the ~ (i.e.: ~/stylesheets/base.css) or you can reconfigure the builtin web server.  (Remember ~ tells ASP.NET to go to the root of the application.)
 
Scott Guthrie posted a useful tip on how to do this.  Here are the basic steps.
 
Step 1: Select the “Tools->External Tools” menu option in VS or Visual Web Developer.  This will allow you to configure and add new menu items to your Tools menu.
 
Step 2: Click the “Add” button to add a new external tool menu item.  Name it “WebServer on Port 8080” (or anything else you want).
 
Step 3: For the “Command” textbox setting enter this value: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\WebDev.WebServer.EXE (note: this points to the web-server that VS usually automatically runs).
 
Step 4: For the “Arguments” textbox setting enter this value: /port:8080 /path:$(ProjectDir)
 
Step 5: Select the “Use Output Window” checkbox (this will prevent the command-shell window from popping up.
  
Once you hit apply and ok you will now have a new menu item in your “Tools” menu called “WebServer on Port 8080”.  You can now select any web project in your solution and then choose this menu option to launch a web-server that has a root site on port 8080 (or whatever other port you want) for the project.
 
You can then connect to this site in a browser by simply saying http://localhost:8080/.  All root based references will work fine
Step 6: The last step is to configure your web project to automatically reference this web-server when you run or debug a site instead of launching the built-in web-server itself.  To-do this, select your web-project in the solution explorer, right click and select “property pages”.  Select the “start options” setting on the left, and under server change the radio button value from the default (which is use built-in webserver) to instead be “Use custom server”.  Then set the Base URL value to be: http://localhost:8080/
 
You can read the whole article here.

Read the complete post at http://www.dotnettipoftheday.com/blog.aspx?id=15

2012 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems