Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Creating Web Sites with ASP.NET 2.0

If you're just starting to create ASP.NET web sites—or just switching to ASP.NET 2.0—you can get up to speed quickly with this handy guide.


advertisement
rom basic, static HTML pages to totally data-driven and data-centric Web applications, the demands on a Web developer are much more complex and demanding than they were just a few years ago. The advent of social networking sites like MySpace, which is written in ASP.NET 2.0; interactive mapping sites; and sites streaming full-motion video has required developers to adapt and change. One of the best tools to use to build these types of web applications is Microsoft's ASP.NET 2.0. This article delves into some of the more interesting features of ASP.NET 2.0 and shows you how to begin using ASP.NET 2.0 on your next web project. The ASP.NET 2.0 feature list is impressive. It ranges from high-level issues such as the project structure architecture all the way down to web control features such as the Focus method, which causes the cursor to appear in a control. ASP.NET 2.0 offers features that every ASP.NET developer will find useful, including:

  • Multiple project types
  • A wide variety of web controls
  • Project folders to help organize files
  • Enhanced code-behind model
  • Master pages and themes
  • Site navigation features
  • Enhanced data access features
  • Membership and personalization
  • Portal architecture including web parts
  • Site administration tools
In this article I'll take a detailed look at a number of these features including Visual Studio 2005 enhancements, the code-behind model, the web controls, the master pages feature, the themes and skins feature, and the site navigation features.
The advent of social networking sites like MySpace, which is written in ASP.NET 2.0; interactive mapping sites; and sites streaming full-motion video has required the Web developer to adapt and change with the times.
Creating a Web Site
With the release of Visual Studio 2005 SP1, Microsoft offers web site developers a choice between two different project types: the Web Site and the Web Application. The Web Site project really is not a project at all since Visual Studio 2005 solution and project files are not created. In the Web Site model all pages and code are stored in a directory, much like the traditional ASP model. When it comes to deployment, the easiest approach is to copy all of your files to your web server and everything compiles on demand. You could also use the aspnet_compiler.exe utility to precompile your site into a binary file and deploy to your web site.

The Web Application project is an implementation of the type of web project available in Visual Studio 2003 and consists of a solution (.sln) and project files (.vbproj). It is the result of Microsoft listening to the ASP.NET 2.0 developer community and responding to the needs of the community. It provides the benefit of generating a single assembly in the local /bin folder ready for deployment. This model also makes it easier to incrementally deploy changes made to your site. If you are converting a web application from Visual Studio 2003, this is the project model you are going to want to adopt. I use this model with most of the web applications I develop. To create a web site with the Web Application project model, launch Visual Studio 2005 and from the File menu option choose New Project… and the New Project dialog box will appear (see Figure 1). Choose ASP.NET Web Application, the name of the project, the location, and the name of the solution if you select to have one created or specify if you want the new project added to the current solution. Click OK and Visual Studio will create the .sln and the .vbproj files (because it's a Visual Basic project), a default.aspx page, and a web.config file.



 
Figure 1: The New Project dialog box specifies the name, location, and language for your web application.
 
Figure 2: The New Web Site dialog box specifies the name, location, and language for your web site.

To create a web site with the Web Site project model, launch Visual Studio 2005 and from the File menu option choose New Web Site and the New Web Site dialog box will appear (see Figure 2). Choose ASP.NET Web Site, the location of the web site, the language used, and lastly, the name of the web site. I don't need to explain the name of the web site and the language you want to use, but I'll discuss other options. The location dropdown offers three options: File System, HTTP, and FTP. Creating a File System Web site is the simplest approach because your web site can reside in any directory on your hard drive or shared network drive. The advantage of a File System web site is that you can run it using Visual Studio 2005's built-in development web server. You don't need IIS (although you can use IIS to run a File System web site by creating a virtual directory for the directory in which you are storing the web site).

 
Figure 3: The web site location can be an FTP folder on a distant server.
Choosing HTTP as the location will direct Visual Studio 2005 to automatically create a web site in an IIS virtual directory. This saves you the step of creating the virtual directory in IIS, but obviously you need to have access to an IIS server. Choosing FTP as the location allows you to actually store and even code your application on a remote web server somewhere. If you've selected this option, click the Browse button to display the Choose Location dialog box and then select a directory, an IIS virtual directory, and then enter the parameters required to log on to an FTP location (see Figure 3).

After you have decided on the name, location, and language for your new web site, click the OK button to create the site. Visual Studio will create a Default.aspx page, web.config file, and an App_Data folder. One primary difference between the Web Site project model and the Web Application project model is that in the Web Site model settings are stored in a web.config file as opposed to a project file.

Editor's Note: This article was first published in the September/October 2007 issue of CoDe Magazine, and is reprinted here by permission.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap