Thursday 15 September 2011

Difference between website and webapplication in vs2005



If you are not very familiar with Visual Studio 2005, a "web site" and "web application project" may sound the same for you.

Microsoft introduced the concept of "website" instead of "web application" in Visual Studio 2005. However, due to demand from the development community, they re introduced the "web Application Project" which is pretty much similar to Visual Studio 2003 web application.

Web site in Visual Studio 2005



A web site is just a group of all files in a folder and sub folders. There is no project file. All files under the specific folder - including your word documents, text files, images etc are part of the web site.

You have to deploy all files including source files (unless you pre compile them) to the server. Files are compiled dynamically during run time.

To create a "web site", you need to use the menu File > New > Website

You will have the option to choose either one of the following location types:

  • File System - Allows you to choose a folder to put all the files.

  • Http - Allows you to choose a virtual directory to put the files.

  • FTP - Allows you to choose an ftp location.

    In any of the above cases, no project file is created automatically. Visual Studio considers all files under the folder are part of the web site.

    There will be no single assembly created and you will nto see a "Bin" folder.

    The benefits of this model is, you do not need a project file or virtual directory to open a project. It is very handy when you share or download code from the internet. You just need to copy the downloaded code into a folder and you are ready to go!

    How to open a web site, if there is no project file?



    It looks bit confusing until you get familiar with the Visual Studio 2005 programming model.

    To open a web site (which do not have a project file), you need to first open Visual Studio 2005 and choose the menu File > Open > Website. It allows you to select a folder (not a project file). Thats all you have to do to view all the files part of the web site.

    Disadvantages of web site model



    Since there is no project file, there is nothing that you can double click to open the web site in Visual Studio for editing. You have to open Visual Studio first and then open the site from VS2005.

    Another disadvantage is, all files under the folder and considered to be part of the web site. There are lot of legacy web sites where more than one web site is combined into one folder, but properly managed the files by including them in appropriate projects. With the new model, since there is no project file, all files are considered to be part of the same website.

    How to exclude a file from a web site in VS2005?



    Many programmers keep lot of document files and backup files under the project folder. With the new model, they are all part of the web site. If you have backup files which has same class names, you may get compilation problems when they are compiled dynamically sicne they will be treated as duplicate classes. The only way you can exclude a file from the website within the same directory is by renaming them with the extension .exclude

    Web Application Project in Visual Studio 2005



    Microsoft introduced the "web site" concept where all files under a web site are part of the site, hoping that the development community is going to love that. In fact, this is very usefull to share code.

    However, they did not consider millions of existing web applications where people are comfortable with the "project" based application. Also, there were lot of web applications where several un wanted files were kept under the web site folder. So, the new model did not work well for them.

    When people started screaming, Microsoft came up with the answer. On April 7, 2006, they announced "Visual Studio 2005 Web Application Projects" as an Add-On to Visual Studio 2005. This Add-On will allow you to create and use web applications just like the way it used to be in Visual Studio 2003.

    The Visual Studio 2005 Web Application Project model uses the same project, build and compilation method as the Visual Studio .NET 2003 web project model.

    All code files within the project are compiled into a single assembly that is built and copied in the Bin directory.

    All files contained within the project are defined within a project file (as well as the assembly references and other project meta-data settings). Files under the web's file-system root that are not defined in the project file are not considered part of the web project.

    Which is best for me - Web site or web application project?



    Both has it's own advantages and disadvantages.

    A web site is good for you if you just want to create web sites and share with others. It is ideal for new projects.

    However, "web application project" is better if you are planning to migrate your Visual Studio 2003 or 2002 web sites into Visual Studio 2005. Otherwise you may end up spending lot of time to exclude unwanted files from your web site folder.

  • No comments:

    Post a Comment