Home > English > Test your website from your mobile device while still developing in Visual Studio

Test your website from your mobile device while still developing in Visual Studio

As you continue to develop new applications and come up with solutions for many new devices, it becomes necessary to be able to test your code in a quick and efficient manner. Sometimes, deploying your code to a web server just for testing does not make sense. It may even be too time consuming to deploy even to your local instance of IIS if all you want to do is view a quick change you made.

The problem with trying to do this while using Visual Studio is that you are always debugging your code using a http://localhost:/xxx address and this does not allow other devices to hit this address directly. Here is a trick/hack that I have learned that may save you some time while developing your web applications.

1. Visual Studio will automatically use Cassini for hosting web projects. We want to change this to use IIS Express as shown in the figure below:

2. Please note that I changed the path of the Project Url to use the computer name along with the port. The original url was pointing to “localhost”.

3. If you hit F5, the application will still not work. Here comes the trick/hack.

4. We need to modify the binding information that IIS Express holds for this application. Open up an instance of Windows Explorer and navigate to the following location providing your own user name and drive letter:
[drive letter]:\Users\[user name]\Documents\IISExpress\config

5. Here we are going to make a modification to the application.config file. It is important to make a backup of this document in case you make a mistake and want to rollback.

6. Navigate the XML document to the following XPath location:
\\Configuration\system.applicationhost\sites

7. Here we will have a listing of all the websites that we are using against IIS Express. Go down to the site that you are wanting to expose as seen in the figure below:

8. Change the binding information from “localhost” to your computer name.

9. Save and close the file.

10. Restart IIS Express. Go to the tray icon and stop IIS Express as shown below:

11. You will be presented a dialog about stopping IIS Express.

12. Finally, hit F5 and run your application.

13. You can now test your site from your mobile device or tablet without deploying. This will allow you to make changes and browse to the location without any added workflow to your development process.

Although, I use this internally when I am developing applications where I need to see the results on a real device, I still think this is a hack and should be treated with caution.

Hope this helps…

Advertisements
  1. October 18, 2011 at 5:04 pm

    Thanks for sharing this type of useful information with us. I have one small question. For testing website, does we require mobile device ?

  2. October 18, 2011 at 5:29 pm

    Hi Chandra Dev,

    No, you are not required to test your website with mobile or tablet devices but if you are developing a site that you want to work on these devices, you can now easily do your testing with what I have proposed.

  3. Sherv
    October 24, 2011 at 3:09 pm

    hi i cant seem to access this through my mobile device any thoughts? im using a samsung android tab, a ipad 2 and a iphone

  4. October 24, 2011 at 3:51 pm

    hi im trying to access my site using this method but i can seem to open this in the mobile browser, should there be any special configgurations or something? Thanks!

  5. October 24, 2011 at 8:26 pm

    sorry i mean can’t, I can’t access this over mobile browsers, this method can be used in other pc’s and laptops on my network

  6. May 10, 2012 at 2:21 pm

    when i try this, i get an iis error after building

    • May 11, 2012 at 11:29 am

      Kristof, it is a bit tricky and if you don’t have it just right, things can go wrong. I will review my post again and make sure that it work or describe any more details that could be left out.

  1. March 20, 2012 at 1:03 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: