Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Introduction to ASP.NET Web Applications in Visual Studio

Visual Studio .NET 2003

Visual Studio .NET allows you to create applications that leverage the power of the World Wide Web. This includes everything from a traditional Web site that serves HTML pages, to fully featured business applications that run on an intranet or the Internet, to sophisticated business-to-business applications providing Web-based components that can exchange data using XML.

This topic provides an overview of the types of Web applications you can create in Visual Studio, how they relate to one another and to other Visual Studio technologies, and suggestions about where to learn more about the types of Web applications you want to create.

Note   For details about the relative advantages of Web applications and Windows applications, see Windows Forms and Web Forms Recommendations.

Visual Studio ASP.NET Web Applications

A Visual Studio Web application is built around ASP.NET. ASP.NET is a platform — including design-time objects and controls and a run-time execution context — for developing and running applications on a Web server.

ASP.NET in turn is part of the .NET Framework, so that it provides access to all of the features of that framework. For example, you can create ASP.NET Web applications using any .NET programming language (Visual Basic, C#, Managed Extensions for C++, and many others) and .NET debugging facilities. You access data using ADO.NET. Similarly, you can access operating system services using .NET Framework classes, and so on.

ASP.NET Web applications run on a Web server configured with Microsoft Internet Information Services (IIS). However, you do not need to work directly with IIS. You can program IIS facilities using ASP.NET classes, and Visual Studio handles file management tasks such as creating IIS applications when needed and providing ways for you to deploy your Web applications to IIS.

Where Does Visual Studio Fit In?

As with any .NET application, if you have the .NET Framework, you can create ASP.NET applications using text editors, a command-line compiler, and other simple tools. You can copy your files manually to IIS to deploy the application.

Alternatively, you can use Visual Studio. When you use Visual Studio to create Web applications, you are creating essentially the same application that you could create by hand. That is, Visual Studio does not create a different kind of Web application; the end result is still an ASP.NET Web application.

The advantage of using Visual Studio is that it provides tools that make application development much faster, easier, and more reliable. These tools include:

  • Visual designers for Web pages with drag-and-drop controls and code (HTML) views with syntax checking.
  • Code-aware editors that include statement completion, syntax checking, and other IntelliSense features.
  • Integrated compilation and debugging.
  • Project management facilities for creating and managing application files, including deployment to local or remote servers.

If you have used Visual Studio before, these kinds of features will seem familiar, because they are similar to features that you get for creating applications in previous versions of Visual Basic and Visual C++. With Visual Studio .NET you can use these kind of features to create ASP.NET Web applications.

Elements of ASP.NET Web Applications

Creating ASP.NET Web applications involves working with many of the same elements you use in any desktop or client-server application. These include:

  • Project management features   When creating an ASP.NET Web application, you need to keep track of the files you need, which ones need to be compiled, and which need to be deployed.
  • User interface   Your application typically presents information to users; in an ASP.NET Web application, the user interface is presented in Web Forms pages, which send output to a browser. Optionally, you can create output tailored for mobile devices or other Web appliances.
  • Components   Many applications include reusable elements containing code to perform specific tasks. In Web applications, you can create these components as XML Web services, which makes them callable across the Web from a Web application, another XML Web service, or a Windows Form, for example.
  • Data   Most applications require some form of data access. In ASP.NET Web applications, you can use ADO.NET, the data services that are part of the .NET Framework.
  • Security, performance, and other infrastructure features   As in any application, you must implement security to prevent unauthorized use, test and debug the application, tune its performance, and perform other tasks not directly related to the application's primary function.

The following diagram provides an overview of how the pieces of ASP.NET Web applications fit together and fit into the broader context of the .NET Framework.

Aa711425.aspnet_frameworkbmp(en-us,VS.71).gif

The sections below outline the different elements of an ASP.NET Web application and provide links to more information about how to work with each element in Visual Studio.

Overview: ASP.NET

The information in this topic provides only an introduction to ASP.NET. For details about what ASP.NET is and what components are involved in an ASP.NET application, see Introduction to ASP.NET.

Project Management: ASP.NET Web Application Projects and Deployment

To work with an ASP.NET Web application using Visual Basic or Visual C#, you use the ASP.NET Web Application project template. As with other Visual Studio projects, a Web application project is a central repository for all the information required to design, run, and manage the application.

When you create a Web application project, Visual Studio creates the necessary files and folders on the server, sets the appropriate security settings on them, and creates the IIS application. For details, see ASP.NET Web Application Template.

Each Web application can maintain a Web.config file that follows the format and conventions of .NET configuration files. In ASP.NET, the configuration file allows you to establish project-specific settings for security, compilation options, tracing, error handling, and more.

For details about how to create and manage ASP.NET Web application projects in Visual Studio, see the following topics.

User Interface: Web Forms and the ASP.NET Page Framework

You can create HTML pages and Web Forms pages as the user interface for your application. HTML pages are generally used for static content. In contrast, Web Forms pages give you a programmable interface that works much like a Visual Basic form, except that the user interface is rendered in a Web browser or other Web device.

Note   You can use a Windows Form as the user interface in an application that calls XML Web services. For an example, see Walkthrough: Creating a Distributed Application.

Web Forms pages are built on the ASP.NET Page framework. Each Web Forms page is an object that derives from the ASP.NET Page class, which acts as a container for controls. The page actually consists of two files: an .aspx file that contains the UI elements (static HTML text and control elements) and a class file that contains the code that runs the page. For details, see Introduction to Web Forms Pages.

When users request a Web Forms page, the Page framework runs the Web Forms page object and all the individual controls on it. The output of the Page class and of the controls is HTML. For details, see Web Forms Page Processing.

Because the Web is inherently stateless — by default, components in a Web application are alive only long enough to process a single request — Web applications face challenges in preserving values as the user works with the application. To help, the Page framework includes facilities for managing state. These include page-based "view state" (a method for preserving values in controls) and access to non-page-based state facilities such as Session state (user-specific) and Application state (global to the application). For details, see Web Forms State Management.

The Page framework supports a set of controls you can use to program user interaction with your Web Forms pages. User actions in the form are captured and processed by the Page framework in a way that lets you treat them as standard events. You can choose from a large selection of controls available in Visual Studio. In addition, you can create your own custom controls. For details, see Introduction to Web User Controls and Developing ASP.NET Server Controls.

Note   You can also create output for mobile devices. To do so, you use the same ASP.NET page framework, but you create Mobile Web Forms instead of Web Forms pages and use controls specifically designed for mobile devices. For details, see Creating ASP.NET Mobile Wep Applications.

For details about Web Forms pages and how to work with them in Visual Studio, see the following topics:

  • Web Forms Pages   Lists topics that provide an overview of Web Forms, including background on ASP.NET and on the Web Forms code model.
  • Creating and Managing Web Forms Pages   Provides information on how to create, add, and manage Web Forms pages.
  • Programming Web Forms   Provides information on the specific aspects of programming in a Web Forms environment.

Web-based Components: XML Web Services

An XML Web service is a component that can be called over a TCP/IP network by other applications. It performs a specific function — anything from calculations and credit card validation to complex order processing— and returns values to the calling application.

What makes XML Web services unique is that they can be called across the Web. XML Web services are invoked using HTTP or SOAP requests and exchange data with other components using XML. As such, they can form an integral part of ASP.NET Web applications, providing services not only to your applications, but also to any application that has Web access, making them ideal for business-to-business transactions.

For information about XML Web Services, how they work with ASP.NET applications, and how you can create them in Visual Studio, see Programming the Web with XML Web Services.

Web Application Data Access

Most ASP.NET Web applications involve at least some level of access to data. ASP.NET does not directly include data access facilities. Instead, Web applications use ADO.NET data services.

ADO.NET provides a complete framework for accessing and managing data from a variety of sources, including databases and XML files or streams. ADO.NET includes providers — classes that allow you to connect to data sources, execute commands, and read results. You can optionally keep data in a dataset, which is a disconnected, in-memory cache.

Data access in Web applications, whether in a Web Forms page or an XML Web service, introduces special challenges:

  • Statelessness   The components of Web applications usually do not preserve state, which makes it impractical to maintain live connections to a data source (or other resources).
  • Scalability   Because Web applications can have user loads that vary substantially over short periods of time, data access has to be designed with scalability in mind.

Visual Studio provides a variety of tools for working with data, including Toolbox support for data elements, various configuration wizards, and so on. The following topics provide information on data in general — that is, ADO.NET — as well as about using data in Web applications.

Web Application Infrastructure: Security, Performance, and More

In addition to giving you the means to create user interface elements and callable components, ASP.NET provides a context for those elements to run in. For example, ASP.NET communicates with IIS to handle requests for Web Forms pages and XML Web services, parse the files, call related components, and so on.

Much of this work occurs beneath the surface, at a level where you do not typically need to program when you are creating desktop applications.

Note   Visual Studio provides limited support for working with ASP.NET infrastructure features. For example, you can edit the Web application configuration file (Web.config) using the Visual Studio Code Editor. But the .NET Framework is both pluggable and extensible, providing you with low-level access if necessary.

There are other aspects of Web applications that you must often contend with that are part of the application's infrastructure. These include:

  • Security   You frequently have to authenticate and authorize users of your Web application. There are special problems associated with security in a Web application, because users are getting access to server-based resources and because you have very little control over the client side of the application (the browser or mobile device). ASP.NET includes security features that you can configure and program against in your Web application.
  • Performance and optimization   You can tune your application's performance by caching pages and data. ASP.NET maintains an output cache that stores pages that have been requested before; by specifying caching settings, you can control how long pages are cached and under what circumstances they are refreshed.
  • Tracing   Because Web applications run on the server — often a remote server — they do not have output other than the application output (a Web Forms page, for example). ASP.NET therefore gives you the opportunity to include trace information directly in a Web Forms page. For details about adding tracing to ASP.NET Web applications, with links to topics that address specific trace procedures, see ASP.NET Trace.

For details about Web Forms security, see the following topics:

For details about Web Forms performance and optimization, see the following topics:

See Also

Web Forms Pages | XML Web Services in Managed Code | ASP.NET Technology Backgrounder | Web Walkthroughs

Show:
© 2015 Microsoft