Configure Projects, Solutions and Reference Assemblies

Configure Projects

There are four project types for creating a web application in Visual Studio, which you should be familiar with for this exam. Namely: ASP.NET Web Site, Empty Web Site, ASP.NET Web Service, and ASP.NET Web Application. We will cover ASP.NET Web Site, and ASP.NET Web Application.

ASP.NET Web Site:

This project type is file-based, and there is no project file included. So every file- whatever its extension would be- in a given folder is the part of your project. This is the default web site project type in Visual Studio (simply click on the New Web Site button on the menu (represented as an Earth globe).

This template generates a web.config file with some initial entries, and a Default.aspx page with the given code-behind file for you. Also an App_Data folder will be included to help you begin your work. The above mentioned Empty Web Site project is exactly the same as this project type, the difference is that you won’t get any content generated at startup.

ASP.NET Web Application:

You can understand the Web Site project type deeper in contrast with an ASP.NET Web Application project. If you’ve ever programmed a Windows Forms Application, you’ll find this project type very familiar. You can set references on assemblies, control the assembly information of your project with the AssemblyInfo.cs file. This type also generates .designer files for your web forms.

This project type includes a project file for your application, and only the files referenced in it will be the part of your web application, whatever else may reside in your project directory.

The compilation of a Web Application project is called classic compilation. All the files, which represent your UI (.aspx and etc) are published without compilation, thus compiled dynamically when the first user requests the page. The code files will be compiled to a single assembly, so you won’t be able to change them later.

Adding References

There are two different scenarios of adding references to assemblies, depending on which project type you use. In the case of a Web Application, simply right click the references folder, and select add reference. Because Visual Studio is responsible for compiling this type, it simply includes your reference in the project file.

When you use a Web Site project type, adding a reference is also very easy, just click on the project name in solution explorer, and select add reference. Because this type of project is compiled by ASP.NET (and not Visual Studio), the web.config file will be modified to include your reference, in the following way:

        <add assembly=”MyAssembly” …./>

Of course, you can do this manually.

Be aware of that when you add a reference to an assembly, which isn’t included in the Global Asembly Cache, Visual Studio will generate a Bin folder in your project, and place the referenced assembly there, regardless of the project type you use. If you’ve added custom assemblies to your GAC, and reference them in your project, then you should include that assembly into your applications Bin folder, and set a reference to that copy. In this manner, you can use the XCOPY or the Copy Web Site tool to deploy your application.

Tags: , , , , ,

Leave a Reply

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

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

%d bloggers like this: