What is ASP.NET - ASP.Net Introduction - .NET Tutorial
What is .Net ?
- Platform that was developed for web development is known as ASP.Net which was in the year 2002.
- ASP.Net works with HTTP Protocol, a standard protocol that is used across all web applications.
- ASP.Net applications can be used in various .net languages like C#,VB.Net, and J#.
- ASP Full form is Active Server Pages and .NET stands for Network Enabled Technologies.
- Popular Microsoft Framework which is used to build Web Applications is ASP.NET.
- It is a part of .Net Framework, hence it is ASP.NET and it is a server side technology like ASP.
- We can build a front end using ASP.NET and WebForms which has webform controls which can be used for generating user interface.
- For Creating backend applications we use C#.
- Webserver used for ASP.NET is called as IIS(Internet Information Services).
- Creation, deployment and execution of WebApplications and WebServices is provided by ASP.NET
ASP.NET Architecture and its Components
- A framework that is used to develop a web based application is called ASP.Net.
- The architecture of the.Net framework is based on the following key components
- Language – .Net Framework uses variety of languages like VB.net and C# which can be used for creating web applications
- Library – A Set of standard libraries are included in the .NET Framework. Most commonly used library for web applications is .net Web Library. This library has all the necessary files for developing .net web based applications.
- Common Language Runtime – The Common Language Infrastructure or CLI is a platform. .Net programs are executed on this platform. To perform key activities CLR is used. Key activities are Exception Handling and Garbage Collection.
Key Characteristics of the ASP.Net framework
Code Behind Mode
- Concept of Design and Seperation is used for maintaining the ASP.Net application. File type of ASP.Net file is aspx.
- Coding part of the page is denoted by Mypage.aspx.cs. Two seperate files for each web page is created one for the design part and other for the code part.
- Asp.net uses the facility to control the state management.
- A state less protocol HTTP is used. Shopping cart application can be given as example.Now, when a user decides what he wants to buy from the site, he will press the submit button.
- The items chosen by the user needs to be remembered by the application. This state is known as remembering state of an application at a current point of time.
- Information on the cart page is not stored by HTTP, when the user goes to the purchase page.To ensure that the cart items to be carried forward to the purchase page we need additional coding which is complex at times. Here state management can be managed by ASP.Net which can remember the cart items and pass it over to the purchase page.
- Concept of Caching is implemented by ASP.Net which improves applications performance.
- User requested caching pages are stored in a temporary location and these caching pages are retrieved faster and better responses can be sent to the user. Hence performance of the application can be improved by caching.
- To launch an ASP.net Application there are several steps which needs to be carried out. These steps are the lifecycle of the application.
- When a request made by the user the life cycle of the ASP.Net starts.
- This request is to the Web server for the ASP.Net Application happens when the user first normally goes to the home page of the application.
- A method called Application start is executed by the webserver at this time where global variables are set to their default values.
- The next stage is the creation of the HttpContext, HttpRequest & HttpResponse by the web server.
- The HttpContext is just the container for the HttpRequest and HttpResponse objects.
- Information about object is contained in the HTTP Request, including cookies and browser information.
- The HttpResponse object contains the response that is sent to the client.
- Webserver creates the object request that are sent to the application is processed by these objects.
- For example, let’s assume we have 2 web applications. One is a shopping cart application, and the other is a news website.
- For both shopping cart and news application, Two HttpApplication objects are created. Any further requests to each website would be processed by each HttpApplication respectively.
- This is the final part of the application. In this part, the application is finally unloaded from memory.
- Before any application instance is destroyed the event is called dispose.
- This method can be used to manually release any unmanaged resources.
Advantages of ASP.NET
Separation of Code from HTML
- Seperate Layout and business logic based coding is a feature of ASP.NET. This feature makes it easier for programmers and designers to collaborate efficiently.
Futuristic Support for compiled languages
- When first requested ASP.NET pages are compiled to byte code and JIT(Just In Time) Compiled. Subsequent requests are compiled fully and it is cached till the source code changes.
Use services provided by the .NET Framework
- Framework of .net provides class libararies that can be used by our application.
- Some of the key classes are input/output, access to operating system services, data access, or even debugging.
Rich GUI - Graphical Development Environment
- For developers visual studio .net provides a rich gui environment. We can set properties using user interface, and has drag and drop controls.
- Auto code completion is one of the additional feature in .NET, which means full intellisense support for C#, HTML and XML Code.
- ASP.NET provides very good solutions for session and application state management in case of server fail and connection break down.
- State information can be kept in memory or stored in a database. It can be shared across web farms .State information can be recovered, even if the server fails or the connection breaks down.
Update files while the server is running
- Asp.NET application can be updated when the server is online and clients are connected. Once new files are copied to the application the framework utilizes these new files.
- Removed or old files that are still in use are kept in memory until the clients have finished the access.
XML-Based Configuration Files
- Configuration settings in ASP.NET are stored in XML files ( web.config files ) that you can easily read and edit. You can also easily copy these to another server too.
Different Validators in ASP.NET
- To validate the user controls we use ASP.NET validation controls. When user enters the input it must always be validated before it is send across to various layers of the application.
- Wrong data can be removed through this validation. So for the safety of an application validation becomes more important.
- Two types of validations are there in ASP.NET,
- Client-Side Validation
- Server-Side Validation
- Validations that are done from the client browser is known as Client Side Validation.
- Some of the Validation Controls in ASP.NET
- RequiredFieldValidator Control
- CompareValidator Control
- RangeValidator Control
- RegularExpressionValidator Control
- CustomFieldValidator Control
Server Side Validation
- Server-Side Validation can be done by applying validation in the server side through c# code.
- Server-Side Validation is a secure form of validation.
- The major advantage of Server-Side Validation is if the user somehow manage to bypass the Client-Side Validation, we can still catch the wrong data in the server-side.