ASP.net Q/A Part 3

on 8:05 AM

What are major events in GLOBAL.ASAX file ?
The Global.asax file, which is derived from the HttpApplication class, maintains a pool
of HttpApplication objects, and assigns them to applications as needed. The Global.asax file contains the following events:
Application_Init: Fired when an application initializes or is first called. It is invoked for all HttpApplication object instances.
Application_Disposed: Fired just before an application is destroyed. This is the ideal location for cleaning up previously used resources.
Application_Error: Fired when an unhandled exception is encountered within the
application.
Application_Start: Fired when the first instance of the HttpApplication class is created.
It allows you to create objects that are accessible by all HttpApplication instances.
Application_End: Fired when the last instance of an HttpApplication class is destroyed.
It is fired only once during an application's lifetime.
Application_BeginRequest: Fired when an application request is received. It is the first event fired for a request, which is often a page request (URL) that a user enters.
Application_EndRequest: The last event fired for an application request.
Application_PreRequestHandlerExecute: Fired before the ASP.NET page framework begins executing an event handler like a page or Web service.
Application_PostRequestHandlerExecute: Fired when the ASP.NET page framework has finished executing an event handler.
Applcation_PreSendRequestHeaders: Fired before the ASP.NET page framework sends HTTP headers to a requesting client (browser).
Application_PreSendContent: Fired before the ASP.NET page framework send content to a requesting client (browser).
Application_AcquireRequestState: Fired when the ASP.NET page framework gets the current state (Session state) related to the current request.
Application_ReleaseRequestState: Fired when the ASP.NET page framework completes execution of all event handlers. This results in all state modules to save their current state data.
Application_ResolveRequestCache: Fired when the ASP.NET page framework completes an authorization request. It allows caching modules to serve the request from the cache,thus bypassing handler execution.
Application_UpdateRequestCache: Fired when the ASP.NET page framework completes handler execution to allow caching modules to store responses to be used to handle subsequent requests.
Application_AuthenticateRequest: Fired when the security module has established the current user's identity as valid. At this point, the user's credentials have been validated.
Application_AuthorizeRequest: Fired when the security module has verified that a user can access resources.
Session_Start: Fired when a new user visits the application Web site.
Session_End: Fired when a user's session times out, ends, or they leave the application Web site.
Note :- During interview you do not have to really cram all these events. But just keep the basic events in mind

What order they are triggered ?
They're triggered in the following order:
Application_BeginRequest
Application_AuthenticateRequest
Application_AuthorizeRequest
Application_ResolveRequestCache
Application_AcquireRequestState
Application_PreRequestHandlerExecute
Application_PreSendRequestHeaders
Application_PreSendRequestContent
Application_PostRequestHandlerExecute
Application_ReleaseRequestState
Application_UpdateRequestCache
Application_EndRequest.

How can we force all the validation control to run ?
Page.Validate

How can we check if all the validation control are valid
and proper ?
Using the Page.IsValid() property you can check whether all the validation are done.
If client side validation is enabled in your Web page, does that mean server side code is not run?
When client side validation is enabled server emit’s JavaScript code for the custom validators. But note that does not mean that server side checks on custom validators do not execute. It does this redundant check two times as some of the validators do not support client side scripting.

Which JavaScript file is referenced for validating the validators at the client side ?
WebUIValidation.js javascript file installed at “aspnet_client” root IIS directory is used to validate the validation controls at the client side

How to disable client side script in validators?

Set EnableClientScript to false.

How can I show the entire validation error message in a message box on the client side?

In validation summary set “ShowMessageBox” to true.

What is Tracing in ASP.NET ?
Tracing allows us to view how the code was executed in detail.

What exactly happens when ASPX page is requested from
Browser?
Note: - Here the interviewer is expecting complete flow of how an ASPX page is processed
with respect to IIS and ASP.NET engine.
Following are the steps which occur when we request a ASPX page :-
√ The browser sends the request to the webserver. Let us assume that the
webserver at the other end is IIS.
√ Once IIS receives the request he looks on which engine can serve this request.
When I mean engine means the DLL who can parse this page or compile and
send a response back to browser. Which request to map to is decided by file
extension of the page requested.
Depending on file extension following are some mapping
√ .aspx, for ASP.NET Web pages,
√ .asmx, for ASP.NET Web services,
√ .config, for ASP.NET configuration files,
√ .ashx, for custom ASP.NET HTTP handlers,
√ .rem, for remoting resources
√ Etc

How do you upload a file in ASP.NET ?
I will leave this to the readers … Just a hint we have to use System.Web.HttpPostedFile class.

ASP used STA threading model, what is the threading model used for ASP.NET ?
ASP.NET uses MTA threading model.

Explain the differences between Server-side and Clientside code?
Server side code is executed at the server side on IIS in ASP.NET framework, while
client side code is executed on the browser.

How do I sign out in forms authentication ?
FormsAuthentication.Signout()

If cookies are not enabled at browser end does form Authentication work?
No, it does not work.
What is the main difference between Gridlayout and FlowLayout ?
GridLayout provides absolute positioning for controls placed on the page. Developers that have their roots in rich-client development environments like Visual Basic will find it easier to develop their pages using absolute positioning, because they can place items exactly where they want them. On the other hand, FlowLayout positions items down the page like traditional HTML. Experienced Web developers favor this approach because it results in pages that are compatible with a wider range of browsers.If you look in to the HTML code created by absolute positioning you can notice lot of DIV tags. While in Flow layout you can see more of using HTML table to position elements which is compatible with wide range of browsers.