You will notice in WebMatrix Beta that the default website as well as new ones you create are bound to localhost. In other words, they can service local traffic only. This default behavior makes a lot of sense since we want users to explicitly opt into the security risk that comes with running over the network. You can verify this is the case by navigating to the Settings section in the Site workspace, as shown below:
The URL shown above is editable so you can try and replace localhost with your machine name (which happens to be vaidesg1 in my case). However IIS Developer Express will error out saying you need administrative rights (see bottom of screenshot below).
You can circumvent this by restarting WebMatrix as an Administrator, but this is a very bad idea for security reasons, especially for external facing sites. For the future, we are looking at adding an option in WebMatrix. However, you can manually configure this to work as shown below.
Step 1 – Configure HTTP.SYS (requires elevation)
In case you weren’t aware, HTTP.SYS is the OS component that both IIS and IIS Developer Express use to handle HTTP requests. By default, HTTP.SYS won’t allow an application running as a standard user to listen over the wire. It is possible to explicitly configure HTTP.SYS to allow external traffic as shown below. However you will need to be an administrator. For more details look at Configuring HTTP and HTTPS. The commands you will need to run in this situation are as follows.
On Vista and Win7, run the following command from an administrative prompt:
netsh http add urlacl url=http://vaidesg:8080/ user=everyone
For XP, first install Windows XP Service Pack 2 Support Tools. Then run the following command from an administrative prompt:
httpcfg set urlacl /u http://vaidesg1:8080/ /a D:(A;;GX;;;WD)
Obviously, you’ll need to replace vaidesg:8080 in the URL with the combo for your site. Also, you’ll need to do this for every URL you want to expose over the wire.
In HTTP.SYS parlance, you are adding a namespace reservation for your URL. If you ever need to get rid of the reservation you added previously, run the following command from an administrative prompt. You should do this if you delete your site, move it to a different port or decide to run it locally.
On Vista and Win7, run
netsh http delete urlacl url=http://vaidesg1:8080/
On XP, run
httpcfg delete urlacl /u http://vaidesg1:8080/
Step 2 – Configure URL binding in WebMatrix
If you haven’t already, go ahead and edit your URL binding to use your machine name instead of localhost. You should now be able to successfully start the website and browse to it from your local machine. There is one additional step to browse to your website from a different machine.
Step 3 – Configure your firewall
Finally, you’ll need to punch a hole in your firewall. The exact steps will vary depending on what firewall product you have running on your computer.
It takes a bit of work but hopefully gets you going for now. We are looking to address this in the future, as I mentioned.