ASP.NET Overview

ASP.NET is a web application development platform from Microsoft. In this article we will see the basic features of ASP.NET and how it simplifies web application development.

ASP.NET is a platform that provides the required services for building web applications. ASP.NET is a part of the .NET framework. So ASP.NET applications have access to the .NET framework such as the classes in the .NET framework. We can develop our applications in any of the languages that are compatible with the common language runtime including Visual Basic and C#.

When creating ASP.NET applications we create the user interface using ASP.NET pages. An ASP.NET page presents information to the user in any browser or client device and implements application logic using server-side code. In ASP.NET pages have code that runs on the server and dynamically generates web pages to the browser or the client device.

In ASP.NET pages, the user interface programming is divided into two parts, the visual part and the logic. The visual part consists of a file containing static markup such as HTML or ASP.NET server controls or both.

The logic for the ASP.NET Web page consists of code that we create to interact with the page. If the code is in a separate file then this file is referred to as the code-behind file.

ASP.NET provides the following features to easily create the web applications:

Object Oriented Model: ASP.NET presents an object model that enables us to think of our web forms as an object. We can program the page in a more intuitive way than in traditional Web applications.

Event-Based ASP.NET Web pages: Provide event handlers for the events that occur on both the client side or server side.

Automatic State management: The ASP.NET automatically maintians the state of the page and its controls, it also provides explicit ways to maintain the state.

ASP.NET Web pages are similar to static HTML pages but they include extra elements that ASP.NET recognizes and processes when the page runs. ASP.NET web pages differ from static HTML pages in the following ways.

A file name extension of .aspx instead of .htm, .html.

An optional @ Page directive or other directive.

Web server controls.

Other then the @ Page directive, we have a few other directives that support additional page-specific options. Other important directives are:

  • @ Import To include namespaces in our code.
  • @ OutputCache To specify that the page should be cached
  • @ Register To register controls for use on the page

Some directives are specific to the type of the file. Like the @Master directive is used in the master pages, and the ASP.NET user controls use a @Control directive.

The Web server controls are similar to HTML form elements. But they are processed on the server, not the client, allowing us to use server code to set their properties.

Also the ASP.NET pages includes code that runs on the server when the page executes. We associate the web page file with the codebehid using the CodeFile attribute of the Page directive.

Each time the web page is posted to the web server, all the data associated with the page is lost.To restore data between round trips, ASP.NET provides certain state management facilities. Some of them are:

  • View state
  • Hidden fields
  • Cookies
  • Application state
  • Session state

In Visual Studio you can create Web application projects or Web site projects. Each type of project has advantages and disadvantages, and it is helpful to understand the differences between them in order to select the best project type for your needs.

Visual Studio gives us two options to create ASP.NET projects, Web application projects and Web site projects. Each type of project has certain advantages that are appropriate to the requirement. One of the main difference between the two is that Web application projects use the project file to keep track of the files in the project whereas the Web site projects includes all the files in the folders in the project. Another difference is that the web site projects are dynamically complied when the page is requested for the first time whereas the web application projects are precompiled before they are deployed on the web server.

Apart from the traditional ASP.NET WebForms model as described above, there are ASP.NET MVC applications that we can create in the ASP.NET that provides certain specific features and advantages over a tradional web forms model.
 

Up Next
    Ebook Download
    View all
    Learn
    View all