Testing your site with IIS express on a mobile device

If you need to test your website for compatibility on mobile devices like smartphones and tablets, it’s much easier to directly access your site than to push your changes to the server to test them. If you’re using IIS express, there are only a few things you need to change in your site configuration to do this.

First, the mobile device you want to test needs to be on the same network as the computer running the site.

1. Go to your project’s properties in Visual Studio. Click on the Web tab and scroll to the Servers section. Make sure that your build parameter is set to ‘Use Local IIS Web server’; at least the ‘Use IIS Express’ checkbox should be checked.
After saving the change, Visual Studio will ask you if you’d like to create the virtual directory for the web project. Say Yes.

2. Get your computer’s IP address on the network.

3. Open your IIS Express applicationhost.config file located at
%systemdrive%:Users<<yourusername>>DocumentsIISExpressconfig

4. Find the site profile for the site you want to test. It will look something like this.
<site name=”<<SiteName>>” id=”5″>
<application path=”/” applicationPool=”Clr4IntegratedAppPool”>
<virtualDirectory path=”/” physicalPath=”C:<<LocationOfSiteFiles>>” />
</application>
<bindings>
<binding protocol=”http” bindingInformation=”*:XXXX:localhost” />
</bindings>
</site>

5. Add another tag to the bindings tag for your computer’s IP address, using the port that your site is running on.
<binding protocol=”http” bindingInformation=”*:XXXX:192.168.X.XX” />

6. Depending on what port your site is running on, you may need to add an incoming rule in your firewall for the port. If you’d like, you can try accessing it without adding the rule first – but most likely you will need to add it. (Sometimes port 80 doesn’t need the rule).

7. Start running the site.

8. Type in the following to the browser on your mobile device: http://ipaddress:port and that will be your local website!

Running over a VPN

If you need to be connected to a VPN in order to run the site, just a couple things to keep in mind.

1. The IP address that you should use in the applicationhost.config file should be your IP address on the VPN, not the IP address on your local network.

2. The mobile device needs to be connected to the VPN.

3. If you are running the site on port 80 and didn’t add an incoming rule for it in the firewall earlier, you will most likely need to add one for accessing it through the VPN.

Possible errors

1. Check to make sure your computer’s IP address is still the same address you have in the applicationhost.config file. Your IP address can change if you use DHCP on your network or if you switch between Wi-Fi and Ethernet.

When not searching for weeds to pull in his non-existent New Mexico lawn, Robert can be found reading requirements documents and translating geekspeak for humans.