ASP.NET Interview Materials

Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.
Inetinfo.exe is the Microsoft IIS server running, handling ASP.NET requests among other things. When an ASP.NET request is received (usually a file with .aspx extension), the ISAPI filter aspnet_isapi.dll takes care of it by passing the request to the actual worker process aspnet_wp.exe.
ASP.NET 2.0 is the umbrella term for the combination of two web development technologies: web sites and web services. VS2005 allows you to apply Rapid Application Development (RAD)
techniques to building web applications: Drag and drop controls onto your form, double-click on a control, and write the code to respond to the associated event.
A typical .NET web application consists of many items: content files (such as .aspx files), source files (such as .cs files), assemblies (such as .exe and .dll files) and assembly information files, data sources (such as .mdb files), references, and icons, as well as miscellaneous other files and folders.

NET Framework 2.0
The .NET Framework sits on top of the operating system, which can be any recently released version of Windows, including Windows 2000, Windows XP, or Windows Server 2003. Currently, the .NET Framework consists of:
· Compilers for five official languages (C#, Visual Basic, Managed C++, J#, and the Jscript scripting language).
· A number of related class libraries, collectively known as the Framework Class Library (FCL)
, that include support for Windows and web applications, data access, web services, and more.
· The Common Language Runtime (CLR), the object-oriented engine at the heart of the Framework that translates the intermediate code generated by the language compilers into the native code required to execute the application.
In ASP.NET applications, an event is typically raised on the client (such as by the user clicking a button displayed in the browser) but handled on the server.
An event message is transmitted to the server via an HTTP POST. ASP.NET automagically (that's a technical term) handles all the mechanics of capturing the event, transmitting it to the server, and processing the event. As the programmer, all you have to do is create your event handlers.

Event Arguments
Events are implemented with delegates. A delegate is an object that encapsulates the description of a method to which you may assign responsibility for handling the event.
All ASP.NET event handlers take two parameters
and return void. The first parameter represents the object raising the event. By convention, it is called sender, though that is not a requirement.

The second parameter, called the event argument, contains information specific to the event if there is any. For most events, the event argument is of type EventArgs, which does not expose any properties. So, the general prototype for an event is the following: Private void EventName (object sender, EventArgs e)
For some controls, the event argument may be of a type derived from EventArgs and may expose properties specific to that event type. For example, the AdRotator control's AdCreated event handler receives an argument of type AdCreatedEventArgs, which has the properties AdProperties, AlternateText, ImageUrl, and NavigateUrl.

Application and Session Events:

An Application_Start event is raised when the application starts. This is a good time to initialize resources that will be used throughout the application, such as database connection strings (but not the database connection itself). An Application_End event is raised when the application ends. This is the time to close resources and do any other housekeeping that may be necessary. Garbage collection will automatically take care of freeing up memory, but if you allocated unmanaged resources, such as components created with languages that are noncompliant with the .NET Framework, you must clean them up yourself.

A session starts when a user first requests a page from your application and ends when the application closes the session or the session times out. A Session_Start event is raised when the session starts, at which time you can initialize resources that will be session-specific, such as opening a database connection, though it is probably better to open a database connection when it is needed and close it immediately when finished with it. When the session ends, there will be a Session_End event.

Page and Control Events
The page and controls all have events that are inherited from the Control class. All of these events pass an event argument of type EventArgs that exposes no properties.

Postback Versus Non-Postback Events:
Postback events cause the form to be posted back to the server immediately. These include click-type events, such as Button.Click. In contrast, many events (typically change events such as TextBox.TextChanged, or selection events, such as CheckBox.CheckedChanged) are considered non-postback because the event is not posted back to the server immediately. Instead, these events are cached by the control until the next time a post occurs. Controls with non-postback events can be forced to behave in a postback manner by setting their AutoPostBack property to true.

IsPostBack:
The Page object exposes the IsPostBack property. This is a read-only Boolean property that indicates if the page is being loaded for the first time or if it is being loaded in response to a client postback. There are many expensive operations (such as getting data from a database or populating ListItems) you will want to perform only the first time the page is loaded. If the page is posted to the server and then reloaded, there will be no need to repeat the operation, since any data entered or populated is retained (using view state) on subsequent posts.

ASP.NET and Browsers
Let's say it just one more time: The browser never sees the ASP.NET server control. The server processes the ASP.NET server control and sends standard HTML to the browser.
ASP.NET considers browsers to be either uplevel or downlevel. Uplevel browsers support script Versions 1.2 (ECMA Script, JavaScript, JScript), Cascading Style Sheets (CSS) and HTML 4.0; typical uplevel browsers would include Internet Explorer 4.0 and later releases. Downlevel browsers, on the other hand, support only HTML 3.2.
ASP.NET can tell you which browser is being used to display the page. This information is made available via the HttpRequest.Browser property. HttpRequest.Browser returns a HttpBrowserCapabilities object whose many properties include a number of Booleans, such as whether the browser supports cookies, frames, and so forth.

ASP.NET Server Control Class Hierarchy
All the ASP.NET server controls that have a visual aspect when rendered to the browser are derived from the WebControl class. This class provides the properties, methods, and events common to all these controls. Among these are common properties, such as BorderColor, BorderStyle, and BorderWidth, and the RenderBeginTag and RenderEndTag methods.
The WebControl class and several other ASP.NET server controls (e.g., Literal, PlaceHolder, Repeater, and XML) derive from System.Web.UI.Control, which derives from System.Object. The Control class provides base properties such as ID, EnableViewState, Parent, and Visible; base methods such as Dispose, Focus, and RenderControl; and life cycle events such as Init, Load, PreRender, and Unload. The WebControl class and the controls derived from Control are in the System.Web.UI.WebControls namespace. All of the properties, events, and methods of WebControl and System.Web.UI.Control are inherited by the ASP.NET server controls.

No comments: