There are a lot of developers out there that create and test web applications on their local computers.  For the most part things are done correctly and everything on their end seems to be correct.  But when they upload or publish it to their hosting service, they get errors and all sorts of different problems.  This can leave a developer confused and scratching their heads.  They go back to their computer, check the code, and everything looks correct.  Then they run their web application on their computer and it pulls up nicely.  No errors and no hint of anything are wrong with the application.  Yet when they publish the files to the web server, it doesn’t work.

Why?

I believe the problem lies in the IDE the developer is using, namely Visual Studio and Web Matrix.   These IDE have a feature that allows you to run your application and view it on your browser directly.   It is commonly known as View in Browser Mode.  Developers use it to quickly debug their web applications and find potential coding problems before they deploy to production.

But these features run off on their own engine behind the scenes.  For the most part they are a great tool to see how the site will be displayed in the browser.  But for more complex applications such as MVC applications, it can be very misleading.

When you use these tools, the IDE engine that will render the site automatically plugs in all the required assemblies and components, thus giving you a false perception that the application is fully functional.  But when you upload it to a hosting web server, the assemblies and components needed to run the application are not attached with the deployment unless you manually set them to be.

If you really want to test your web application before you deploy it to a production server, install IIS Server on your computer.  For Windows 7 and Windows Vista, it already comes with IIS, you merely have to enable it.  The application can be enabled in Control Panel/Programs/Turn Windows Features On/Off.  Scroll down and install all of the IIS components.  IIS stands for Internet Information Services, and it is the application that Microsoft uses to publish a web site.  The root will be created under C:/Inetpub/wwwroot.  Copy your test site into that folder and in your browser type; http://localhost.  IIS will automatically serve it to you just as a production web server would.

You will be surprised to see that it may generate an error, while the View in Browser mode in your IDE it is displayed without any problem.  This is a tell-tale sign that something is missing, and if your IIS web service cannot render the page correctly on your local computer, you can be fairly sure it will not be rendered correctly on a web hosting production server.

 

2 Responses to Beware the IDE Browser View Mode

  1. Chad says:

    Good suggestion. Keep ‘em coming!

  2. jrummell says:

    Visual Studio 2010 and WebMatrix also support IIS Express, which is essentially IIS7. You can install it on Windows XP, Vista and 7.

    http://learn.iis.net/page.aspx/868/iis-express-overview/

Have a comment? Make it here!