[ASP.NET] Creating Web Sites or Web Application

ASP.NET provides many templates to start the web development. Your choice will be in 2 big categories: web sites or web applications. VS 2010 provides more templates such as MVC applications. MVC 3 even add more templates.  

1. Web Sites vs. Web Applications

Web Sites (so called “projectless development“) are designed to keep your website directory clean without any extra files, which do not need to be deployed. Web applications, in other words, uses the solution and the projects to sync all your files and pages.

There are some pros and cons for each side.

2.  Web Sites

Web sites are easy to deploy and easy to manage. There are several types of web sites you can create in Visual Studio.

– File System Web Site –

  • used when IIS is not installed on the developer’s computer and the developer wants to create a Web site without the use of a remote Web server
  • stored all files inside the selected folder
  • use the lightweight ASP.NET development server
  • run and debug a web site locally without a local IIS

– FTP Web Site –

  •  used when building a web site that is being hosted on a remote computer that does not have Front Page Server Extensions installed
  • FTP used TCP and requires 2 ports (20: data port, 21: command port)
  • Active mode is the default mode. It starts with the client selection of 2 ports (n, n+1). The client uses the port n to initiate the communication to port 21 of the server. When the server responds, the client sends a “port” command. The server initiates data communication from port 20 to the client port n+1. (If the client has a firewall installed, server’s initiation may be blocked.)
  • Passive mode can solve the communication problems when the client has to go through a firewall. When the passive mode is used, the client sends a “pasv” command when the server responds to the client’s request. Then the server selects a random port for data communication and the client initiates data communication.

– HTTP Web Site –

  •  used when IIS is installed on the developer’s computer or on a remote computer with Front Page Server Extensions installed

MVC 3 allows you to create another type of a web site using Razor syntax.

3. Web Applications

Web Applications are organized with projects. It requires extra steps to deploy the application but there are also benefits you can consider.

  • You can manage multiple web applications in a single solution.
  • There are some tools to help the deployment easier such as Web packages.

VS 2010 shipped with MVC 2 and you can download and install MVC3 too. You can see MVC2 and MVC3 application templates separately.

4. Solution File

In Visual Studio, you are working in a solution all the time. Even when you are working with a web site, the solution is used. (The hiddden solution files are  located in the “My Documents\Visual Studio 2010\Projects”)

There are 2 solution files: The “Solution File (.sln)” is a text resource file, which contains general information. The “Solution User Option File (.suo)” file is a binary file, which contains more development specific environment data.

– .sln –

  • A list of the projects in a solution
  • The target framework version
  • The default programming language
  • A list of project dependencies
  • Source control information
  • A list of add-ins

– .suo –

  • The task list
  • Debugger break points
  • Visual Studio Windows locations

5. Dynamic Compilation

When you use the “Web Site” model, the pages do not need to be compiled before deployment. Dynamic compilation refers to the delayed compilation of Web pages that takes place when a user requests a web page

  • Pros: Changes to a file in a site will result in an automatic recompilation; the entire application does not need to be recompiled every time a change is made to a single page; Pages that contain compile errors do not prevent other pages in the site from running
  • Cons:  It requires the first user to take a compilation performance hit

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s