Partager via


Web Pages and Projects

Web Forms pages are one way to create the user interface of an ASP.NET–based Web application. You can add Web Forms pages to several types of Visual Studio projects. Most often, when you want to work with Web Forms pages, you will use the ASP.NET Web Application project template. For more information about Web project templates, see "Simplified Web Site Templates" in What's New in Web Projects. For general information about ASP.NET Web applications, see Types of Web Sites in Visual Web Developer.

To work with a Web Forms page in Visual Studio, you use the Web Forms Designer. The designer includes a WYSIWYG view, called Design view, for laying out the elements of the page. Alternatively, you can switch the designer to an HTML view, called Source view, which gives you direct access to the ASP.NET syntax of the elements on the page. Finally, the designer includes a code editor with IntelliSense that you can use to create the page initialization and event-handler code for your page. For more information, see ASP.NET Web Pages Overview.

Project Files Created With Web Forms

When you create a Web project, Visual Studio constructs a Web application directory structure on the target Web server, and a project structure on your local computer. The following table describes the files that relate to your Web Forms pages.

Note

You need to have appropriate privileges on the Web server computer to create and manage Web application files. For details, see Securing ASP.NET Web Sites.

File Created

Description

WebForm1.aspx and WebForm1.aspx.vb files for Visual Basic Web applications

—or—

WebForm1.aspx.cs files for Visual C# Web applications

These two files make up a single Web Forms page. The .aspx file contains the visual elements of the Web Forms page, for example HTML elements and Web Forms controls. The WebForm1.aspx.vb class file is a hidden, dependent file of WebForm1.aspx. It contains the code-behind class for the Web Forms page, containing event-handler code and the like. For more information, see Web Forms Code Model.

AssemblyInfo.vb files for Visual Basic projects

—or—

AssemblyInfo.cs for C# projects

A project information file (AssemblyInfo.vb or AssemblyInfo.cs file) that contains metadata about the assemblies in a project, such as name, version, and culture information. For details on data contained in the assembly file, see Assembly Manifest.

Web.config file

An XML-based file that contains configuration data on each unique URL resource used in the project. For more information, see Application Configuration Files.

Global.asax and Global.asax.vb files

—or—

Global.asax and Global.asax.cs files

An optional file for handling application-level events. This file resides in the root directory of an ASP.NET application. The Global.asax.vb class file is a hidden, dependent file of the Global.asax file. It contains the code for handling application events such as the Application_OnError event. At run time, this file is parsed and compiled. For more information about Global.asax file usage, see How to: Handle Application-Level Errors.

Styles.css file

A cascading style sheet (CSS) file to be used within the project. For more information, see Working with CSS Overview.

Deployment

The server on which you create your Web Forms pages is typically not the server on which you will deploy the pages and their associated files for production. To deploy a Web project containing Web Forms pages, you may follow one of two approaches:

  • Copy your project to the Web server.

  • Create a deployment project.

For more information about these options, see Deployment of a Web Setup Project.

See Also

Concepts

Using Solution Explorer

ASP.NET Authorization

Introduction to Solutions, Projects, and Items

Deployment of a Web Setup Project

Other Resources

Web Site Projects and Solutions