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:
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…
Here are the slides for the presentation I made on the WCF Web API.
Look forward to doing it again!