Skip to main content

ASP.NET Programming Model



ASP.NET 3.5 features Asynchronous JavaScript and XML (AJAX), Integration with Windows Communication Foundation (WCF), and Language Integrated Query (LINQ).

What’s ASP.NET and Why?
ASP.NET is the abstract programming model it propounds the Web Form Model, and ASP.NET comes as native part of the Microsoft .Net Framework allows access to all power of .Net.

Future: Dynamic Language Runtime (DLR) where the next version of the SilverLight will be. SilverLight support a subset of the WPF.

ASP.NET is Web Form based and event driven programming.

HTTP Request:
HTTP Packet travels over a TCP connection.

Following information can be found in an HTTP Request.

User Agent: The type of browser that originated the request.
Connection: Close a connection or keep alive.
If-Modified-Since: Provides client side cache Validation.

A blank link (of Carrige Return + line-Feed pair) separate the headers from the content.

Server Side Abstraction:
When an aspx request comes to IIS it forwards it to ISAPI extension module to handle it.

In ASP.NET 2.0 and Later Page code can be precompiled and deployed as ana assembly.
HtmlGenericControl is used for less familiar tags like <span>, <font>, and <iframe>.

Adaptive Rendering: Render controls according to their requestee. Visit: www.asp.net/cssadapters

Page Framework:
          Page Events
          Page Scripting (Java Scripiting + AJAX)
          Page Personalizing (Saving user specific information)
          Page Styling (Skins and Themes)
          Page Prototyping (Master Pages)

The Http Runtime:
The HttpRequest is picked by IIS, given an identification token and passed to the ASP.NET ISAPI extention (aspnet_isapi.dll) the entry processing for .Net related processing.

IIS 5.X à Request à aspnet_isapi.dll à aspnet_wp.exe à Load CLR à creates a separate AppDomain for each Web Application

aspnet_wp.exe runs under a restricted account.

aspnet_isapi.dll + aspnet_wp.exe provides following features:
·         Process Recycling
·         Page output caching
·         Memory Monitoring
·         Thread pooling

IIS 6.0 and Later(w3wp.exe) à aspnet_isapi.dll à Loads CLR à creates a separate AppDomain for each Web Application
           
System HTTP Modules:
System HTTP modules are ASP.NET counterpart of ISAPI filters. ASP.NET applications inherit a few system HTTP modules as defined in the machine.config. Preinstalled modules provide features such as authentication, authorization, and session related services.

An HTTP module can preprocess and postprocessa request and it intercepts and handles system events as well as events raised by other applications.

Application Configuration:
Machine.config, web.config, etc

Application Services:
Authentication, state management, caching, membership, role management, and personalization.

The ASP.NET provider model:
It’s the implementation of the strategy pattern. It’s about exposing the internal implementation through well defines interface so that client may unplug the default implementation and plug-in his own implementation.

The Adapter Pattern:
If you have some implementation already and want to plug-in it new framework use adapter pattern that illustrates: Implement an A in class B that framework class C understand and wrap your existing code into that interfaces implementation.

Implementation of the ASP.NET Provider Model:
Provider model consist of Provider classes, configuration layer, and storage layer.

Provider classes:
          A provider class implements an interface known to its clients. ASP.NET uses base classes instead of interfaces.

All provder classes inherit from the ProviderBase class that exposes an inheritable method Initialize() to which settings read from configuration are passed.

Interface VS Base Classes:
Uses interface and you may reach a situation when you convert them to abstract classes.

A base class defines a common behavior and a common programming interface for a tree of child classes. Classes are more flexible and provide versining support.
Versioning support means you can add new methods safely to the base class without requiring the other classes to implement them.

Configuration Layer:
          Each supported class type is assigned a configuration section in configuration file. The content of the section are passed as an argument to the Initialize() method of the ProviderBase class.

Storage Layer:
          Storage detail are packed in the configuration section of the provider. E.g.: AspNetSqlProvider will require connection string, userid, pwd etc.

Availble ASP.NET Provider Base Classes:

MembershipProvider, PersonalizationProvider, ProfileProvider, ProtectedConfigurationProvider, RoleProvider, SessionStateStoreProviderBase, SiteMapProvider, WebEventProvider.

Download ASP.Net Provder toolkit from:

Popular posts from this blog

Culture Information and Localization in .NET

Namespace: System.Globalization CultureInfo Class:                 It provides information like the Format of numbers and dates, Culture’s Calendar, Culture’s language and sublanguage (if applicable), Country and region of the culture. The Basic use of CultureInfo class is shown here: • How string Comparisons are performed • How Number Comparison & Formats are performed • Date Comparison and Formats. • How resources are retrieved and used. Cultures are grouped into three categories: Invariant Culture : It’s Culture Insensitive. It can be used to build some trial application. It can be also used to build an application with hard-coded expiry date that ignores cultures. But using it for every comparison will be incorrect and inappropriate. Neutral Culture : English(en), Frensh(fr), and Spanish(sp). A neutral culture is related to language but it’s not related to specific regi...

Concept of App Domain in .Net

Creating Application Domains: Application domain is just like process, provides separate memory space, and isolates from other code. But it’s quite light weight. It also provides the following advantages: 1-       Reliability : If a domain crashes, it can be unloaded. Hence doesn’t affect the other assemblies. 2-       Efficiency : Loading all assemblies in one domain can be cumbersome and can make the process heavy but Appdomains are efficient in this manner. Important properties of AppDomain: ApplicationIdentity , ApplicationTrust , BaseDirectory , CurrentDomain , DomainManager , DomainDirectory , Evidence , FriendlyName , ID , RelativeSearchPath , SetupInformation , ShadowCopyFiles . Important methods of AppDomain: ApplyPolicy , CreateCOMInstanceFrom , CreateDomain , CreateInstance (Assembly). To create an AppDomain: AppDomain adomain = AppDomain.CreateDomain(“D”); To execute an assembly:...

ASP.NET Working With Data-Bound Web Server Controls

Suppose we have: List<Car> vCars = new List<Car>(); There are three types of databound controls: Simple databound controls(List, AdRotater), Composite data bound controls(GridView, DetailsView, FormView that inherit from CompositeDataBoundControl), and Hierarchal data bound controls (TreeView, Menu).   DataBoundControl has a DataBind method that can be used when data is ready. It calls DataBind for child controls as well. Page.DataBind() will call DataBind for all child controls. Using DataSource Objects:                                       BaseDataBound control exposes DataSource property that accepts objects that implement IEnumerable , IListSource , IDataSource , or IHierarchalDataSource . DataSourceID accepts ID of SqlDataSource . If both specified Data...