Language

Create the Project

By Erik Reitan|

Download Wingtip Toys Sample Project (C#) or Download E-book (PDF)

This tutorial series will teach you the basics of building an ASP.NET Web Forms application using ASP.NET 4.5 and Microsoft Visual Studio Express 2013 for Web. A Visual Studio 2013 project with C# source code is available to accompany this tutorial series.

In this tutorial you will create, review, and run the default project in Visual Studio, which will allow you to become familiar with features of ASP.NET. Also, you will review the Visual Studio environment.

What you'll learn:

  • How to create a new Web Forms project.
  • The file structure of the Web Forms project.
  • How to run the project in Visual Studio.
  • The different features of the default Web forms application.
  • Some basics about how to use the Visual Studio environment.

Creating the Project

  1. Open Visual Studio.
  2. Select New Project from the File menu in Visual Studio.

    Create the Project - New Project Menu Item

  3. Select the Templates -> Visual C# -> Web templates group on the left.
  4. Choose the ASP.NET Web Application template in the center column.
  5. Name your project WingtipToys and choose the OK button.

    Create the Project - New Project Dialog

    Note   The name of the project in this tutorial series is WingtipToys. It is recommended that you use this exact project name so that the code provided throughout the tutorial series functions as expected.

  6. Next, select the Web Forms template and choose the Create Project button.

    Create the Project - New Project Template

The project will take a little time to create. When it’s ready, open the Default.aspx page.

Create the Project - New Project Template

You can switch between Design view and Source view by selecting an option at the bottom of the center window. Design view displays ASP.NET Web pages, master pages, content pages, HTML pages, and user controls using a near-WYSIWYG view. Source view displays the HTML markup for your Web page, which you can edit.

Reviewing the Project

In Visual Studio, the Solution Explorer window lets you manage files for the project. Let’s take a look at the folders that have been added to your application in Solution Explorer. The web application template adds a basic folder structure:

Create the Project - Solution Explorer

Visual Studio creates some initial folders and files for your project. The first files that you will be working with later in this tutorial are the following:

File

Purpose

Default.aspx

Typically the first page displayed when the application is run in a browser.

Site.Master

A page that allows you to create a consistent layout and use standard behavior for pages in your application.

Global.asax

An optional file that contains code for responding to application-level and session-level events raised by ASP.NET or by HTTP modules.

Web.config

The configuration data for an application.

Running the Default Web Application

The default Web application provides a rich experience based on built-in functionality and support. Without any changes to the default Web forms project, the application is ready to run on your local Web browser.

  1. Press the F5 key while in Visual Studio.
    The application will build and display in your Web browser.

    Create the Project - Default Page

  2. Once you have completed review the running application, close the browser window.

There are three main pages in this default Web application: Default.aspx (Home), About.aspx, and Contact.aspx. Each of these pages can be reached from the top navigation bar. There are also two additional pages contained in the Account folder, the Register.aspx page and Login.aspx page. These two pages allow you to use the membership capabilities of ASP.NET to create, store, and validate user credentials.

ASP.NET Web Forms Background

ASP.NET Web Forms are pages that are based on Microsoft ASP.NET technology, in which code that runs on the server dynamically generates Web page output to the browser or client device. An ASP.NET Web Forms page automatically renders the correct browser-compliant HTML for features such as styles, layout, and so on. Web Forms are compatible with any language supported by the .NET common language runtime, such as Microsoft Visual Basic and Microsoft Visual C#. Also, Web Forms are built on the Microsoft .NET Framework, which provides benefits such as a managed environment, type safety, and inheritance.

When an ASP.NET Web Forms page runs, the page goes through a life cycle in which it performs a series of processing steps. These steps include initialization, instantiating controls, restoring and maintaining state, running event handler code, and rendering. As you become more familiar with the power of ASP.NET Web Forms, it is important for you to understand the ASP.NET page life cycle so that you can write code at the appropriate life-cycle stage for the effect you intend.

When a Web server receives a request for a page, it finds the page, processes it, sends it to the browser, and then discards all page information. If the user requests the same page again, the server repeats the entire sequence, reprocessing the page from scratch. Put another way, a server has no memory of pages that it has processed—pages are stateless. The ASP.NET page framework automatically handles the task of maintaining the state of your page and its controls, and it provides you with explicit ways to maintain the state of application-specific information.

Touring Visual Studio

The primary windows in Visual Studio include the Solution Explorer, the Server Explorer (Database Explorer in Express), the Properties Window, the Toolbox, the Toolbar, and the Document Window.

Create the Project - NuGet Dialog Box

For more information about Visual Studio, see Visual Guide to Visual Web Developer.

Summary

In this tutorial you have created, reviewed and run the default Web Forms application. You have reviewed the different features of the default Web forms application and learned some basics about how to use the Visual Studio environment. In the following tutorials you'll create the data access layer.

Additional Resources

Choosing the Right Programming Model
Web Application Projects versus Web Site Projects
ASP.NET Web Forms Pages Overview

Author Information

Erik Reitan

Erik Reitan – Erik Reitan is a Senior Programming Writer at Microsoft. During his spare time he enjoys developing Windows Phone and Windows 8 apps. Follow him on Twitter at @ReitanErik.