http://www.intrepidstudios.com/blog/2010/7/11/debug-your-net-web-project-with-iis-express-t.aspx
Update: IIS Express has been officially released as a standalone installation.
For those of us too impatient to wait for Visual Studio SP1 to natively support IIS Express, I've done some digging and found a way to [fairly] easily setup a debugging environment for IIS Express and VS 2010 (should work for VS 2008 also, though!). This assumes you are at least an intermediate user of .NET/IIS and Visual Studio.
It's actually quite simple to setup IIS express. Once IIS Express is done installing, go to "My Documents\IISExpress8\config".
Right-click "applicationhost.config" and open in your favorite text editor.
Go to line 145. Notice the <sites> element. This is where we can configure our website for IIS Express. Copy the site that is already there and add another entry below it.
Remove the "autoStart" attribute for the first site.
This should be self-explanatory, but in case it isn't, we are setting up a root site in IIS:
Let's test it out! Save the config file and close it.
Go to Run… and type in the following command:
"C:\Program Files (x86)\Microsoft WebMatrix\iisexpress.exe" /site:{YOUR_SITE_NAME}
Replace "{YOUR_SITE_NAME}" with the name you gave the site in the config file above. If you are on 32-bit windows, omit the " (x86)" part after Program Files.
Side Note: You can get a list of command-line switches by going into Command Prompt and typing in "iisexpress /?". You'll notice you can also directly launch any site by physical path and desired port.
Now open your browser and browse to the URL of your site! Voila, it should work (or not, in my case… but that's because this isn't my dev machine):
You might want to create a shortcut on your desktop to the run command I had you type in earlier. It will make it a lot easier to start IIS Express when you're developing.
Note: Now that you've set up this web site, you could manage it from the WebMatrix GUI if you prefer that method for more advanced settings.
Go ahead and open up your solution in Visual Studio.
Right-click on your web project and go to Properties, then the Web tab. Click the "Start URL:" radio button and put in the path to your site:
Then below it, click the "Use Custom Web Server:" radio button and again put the path to the URL:
Next, and this is important, uncheck everything below it. Visual Studio will try to attach to the non-existent IIS server otherwise and not let you debug. We're sort "tricking" it into using IIS Express.
Save and close the project's properties. Now hit Alt-F8 to open up Macro Explorer. Right-click on the My Macros –> Module 1 node and click "Add Macro."
Use the following macro:
Source:
1.
Public
Sub
AttachToIISExpress()
2.
For
Each
process
As
EnvDTE.Process
In
DTE.Debugger.LocalProcesses
3.
If
(process.Name.IndexOf(
"iisexpress.exe"
) <> -1)
Then
4.
process.Attach()
5.
End
If
6.
Next
7.
End
Sub
That is it. The process to follow is:
If you're like me, right-clicking and running the macro is too much work! So let's create a keyboard shortcut, shall we? How about 'F4'?
Go to Tools –> Customize… then click the "Commands" tab. Select "Debug" in the "Menu bar:" drop-down.
Click "Add Command…" and click "Macros" in the left-hand list. Click the IISExpress macro.
Now just rearrange the list to your liking. You can click the newly added command and then click Modify Selection –> Rename.
Click Close and close the customize dialog.
Go to Tools –> Options. Click Keyboard in the left-hand list. Start typing "view.prop" to find the Properties Window keyboard shortcut (already assigned to F4). Hit Remove to get rid of the F4 shortcut.
Now type in "iis" to filter down to the IIS macro. In the shortcut keys box, hit F4, then Assign.
All done! Now instead of right-clicking the macro every time, you only need to hit F4 after you hit F5.
Remember that this is just a temporary workaround until Scott and his ninja team release a hotfix for Visual Studio to enable native IIS Express integration. I needed this functionality this weekend while working on a project (due to how Cassini handled URL requests and because attaching to IIS 7 for debugging was not working for me).
I hope this helps some other fellow curious developers. As always, leave a comment if you have a suggestion to streamline this even more (I attempted to wrap the whole debug process into one macro with no success… maybe someone smarter than me can!).
------------------------------------------------------------------------------------------------
http://johan.driessen.se/posts/Accessing-an-IIS-Express-site-from-a-remote-computer
Allow incoming connections
If you’re running Windows 7, pretty much all incoming connections are locked down, so you need to specifically allow incoming connections to your application. First, start an administrative command prompt. Second, run these commands, replacing 192.168.1.42:58938 with whatever IP and port you are using:
> netsh http add urlacl url=http://192.168.1.42:58938/ user=everyone
This just tells http.sys that it’s ok to talk to this url.
> netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=58938 profile=private remoteip=localsubnet action=allow
This adds a rule in the Windows Firewall, allowing incoming connections to port 58938 for computers on your local subnet.
And there you go, you can now press Ctrl-F5 in Visual Studio, and browse you site from another computer!