Floating FB popout byF5debug

Interview Questions and Answers on .Net Framework, OOPS, ASP.Net, C#.Net, SQL Server, WCF Series – Part 16

 

Question 151 – What is an ASP.NET Application and Page Life Cycle?

ASP.NET creates an environment which can process the request. i.e. creates application object, request, response and context objects
Once environment is created, the request is processed through a series of events which is processed by using modules, handlers and page objects. MHPM (Module, handler, page and Module event)


Question 152 – What are the Steps for ASP.net environment creation?

Step 1    IIS checks which ISAPI extension can server and pass to respective. e.g. aspx page to aspnet_isapi.dll
Step 2    If first request then ApplicationManager creates a Application Domain.
Step 3    App Domain will create hosting environment (HttpRuntime) object, then core objects like HttpContext, HttpRequest and HttpResponse will be created.
Step 4    Once core objects created, HttpApplication is created, if global.aspx is available then object for that will be created. global.asax file inherits from ‘HttpApplication’ class
Step 5    The HttpApplication object is then assigned to the core ASP.NET objects(HttpContext, HttpRequest and HttpResponse) to process the page.
Step 6    HttpApplication then starts processing the request by the following format HTTP module events, handlers and page events. (MHPM)
Step 7    (M: HttpModule): Client request processing starts. Used when we want to inject logic in events of ASP.NET pipeline. It is an event based processor. 6 important events we can utilize before page object is created BeginRequest, AuthenticateRequest, AuthorizeRequest, ResolveRequestCache, AcquireRequestState and PreRequestHandlerExecute. 
Step 8    (H: ‘HttpHandler’): Used when we want to inject logic based in file extensions like ‘.ASPX’, ‘.HTML’. It is an extension based processor. Once above 6 events fired, ASP.NET engine will invoke ProcessRequest event.
Step 9    (P: ASP.NET page): ASP.NET page object will be created. There are 6 important events - Init, Load, validate, event, render and unload. SILVER to remember the events S – Start , I – (Init) , L (Load) , V (Validate), E (Event) and R (Render).
Step 10    (M: HttpModule): Once the page object is executed and unloaded from memory, HttpModule provides post page execution events which can be used to inject custom post-processing logic. There are 4 important post-processing events PostRequestHandlerExecute, ReleaserequestState, UpdateRequestCache and EndRequest.

Question 153 – What is the ASP.NET Page Life Cycle?

Section
Event
Description
HttpModule BeginRequest Signals a new request; guaranteed to be raised on each request.
HttpModule AuthenticateRequest Signals Asp.Net runtime is ready to authenticate the user.
HttpModule AuthorizeRequest Signals Asp.Net runtime is ready to authorize the user.
HttpModule ResolveRequestCache Asp.Net runtime determines Page can be loaded from Cache or to load completely. Caching logic can be implemented here.
HttpModule AcquireRequestState Signals Asp.Net runtime is ready to acquire session variables.
HttpModule PreRequestHandlerExecute Before handling over the control to handler if we needed to perform any tasks.
HttpHandler ProcessRequest Write logic which needs to be executed as per page extensions.
Page Init Creating controls dynamically, in case you have controls to be created on runtime. Any setting initialization. Master pages and the settings. We do not have access to viewstate, postedvalues and neither the controls are initialized.
Page Load Asp.Net controls are fully loaded and write UI manipulation logic.
Page Validate Any valuators on your page, If we like to check the same here.
  Render Like to make some changes to the final HTML which is going out to the browser, you can enter your HTML logic here.
Page Unload Page object is unloaded from the memory.
HttpModule PostRequestHandlerExecute Any logic you would like to inject after the handlers are executed.
HttpModule ReleaserequestState Like to save update some state variables like session variables.
HttpModule UpdateRequestCache Before you end, if you want to update your cache.
HttpModule EndRequest Last stage before your output is sent to the client browser.

 

Question 154 – What is a Directive in ASP.Net?

Directives specify settings that are used by the page and user-control compilers when the compilers process ASP.NET Web Forms pages and user control files. There are 11 types of directives in asp.net and are as follows

  • @Page - Enables you to specify attributes and values for an Asp.Net Page to be used when the page is parsed and compiled.
  • @Master - It is quite similar to the Page directive. The Master directive belongs to Master Pages that is .master files.
  • @Control - It is used when we build an Asp.Net user controls. The @Control directive helps us to define the properties to be inherited by the user control. These values are assigned to the user control as the page is parsed and compiled.
  • @Register - Associates aliases with namespaces and classes, which allow user controls and custom server controls to be rendered when included in a requested page or user control.
  • @Reference -  Links a page, user control, or COM control to the current page or user control declaratively.
  • @PreviousPageType - Creates a strongly typed reference to the source page from the target of a cross-page posting.
  • @OutputCache - It controls the output caching policies of the Asp.Net page or user control.
  • @Import - Imports a namespace into a page or user control explicitly.
  • @Implements - It gets the Asp.Net page to implement a specified .NET framework interface.
  • @Assembly - It is used to make your ASP.NET page aware of external components.
  • @MasterType - To access members of a specific master page from a content page, you can create a strongly typed reference to the master page by creating a @MasterType directive.

Question 155 – What are the different Validation Controls in ASP.Net?

  • Required Field Validator – Makes an input control as a required field.
  • Range Validator – Check that the users input falls under a specific range.
  • Compare Validator – Compare the value of 1 input control to other input control or to fixed value.
  • Regular Expression Validator – Ensure the value of 1 input control matches a specified pattern.
  • Custom Validator – we can write our own validation logic, e.g. we can check for values at run time.
  • Validation Summary – Displays report of all the validation errors of current page.

Question 156 – What is the Difference between User Control and Custom Control?

User Controls

Custom Controls

Easier to create

Harder to create

Complied at runtime

Pre-complied control

Cannot be added to tool box

Can be added to toolbox

Good for Static layout

Good for dynamic layout

Not complied in to dll

Complied into dll

HTML Design(Visual Design possible)

No Visual Design, HTML needs to be declared programmatically

One user control cannot be used in different projects

one custom control can be used in different projects


Question 157 – What is the Difference between Client Side and Server Side Code?

Client Side
Server Side
Code is written in a scripting language such as JavaScript and HTML Code is written in VB, C# or other compiled languages
The browser itself executes the code in response to a user action and no server round trip is involved Code is executed by the server during a roundtrip in response to a user request or action
Client browser executes code to dynamically modify the HTML. This is called Dynamic HTML The server executes server side code and returns HTML code to the client browser for display
Code is script and therefore it is interpreted Code is either compiled dynamically or precompiled into assemblies

 

Question 158 – What is the Difference between Server.Transfer and Response.Redirect?

Server.Transfer
Response.Redirect
There is no Round trip There is a Round trip
Previous page values are accessible Previous page values are not accessible
Performance wise its better Less performance
Information can be preserved in Server transfer through a parameter called preserveForm A state can be maintained in Response redirect but has a lot of drawbacks

 

Question 159 – What are the different IIS Isolation Levels in ASP.Net?

IIS5 supports three isolation levels

  • Low (IIS Process)
        • ASP pages run in INetInfo.Exe, the main IIS process
        • ASP crashes, IIS crashes
  • Medium (Pooled)
        • ASP runs in a different process, which makes this setting more reliable
        • If ASP crashes IIS won't.
  • High (Isolated)
        • Each ASP application runs out-process in its own process space
        • If an ASP application crashes, neither IIS nor any other ASP application will be affected


Question 160 – What are the different Authentication Modes available in ASP.Net?

  • Windows
  • Form
  • Passport
  • None

 

Disclaimer – F5debug Interview Questions & Answers Series:

You may recopy extracts from these pages ("the material") to individual third party websites or to any intranet websites, but only if:
You acknowledge www.f5debug.net as the source of the material. Such acknowledgment should include reference to www.f5debug.net in the copy of the material and should also include “© Karthikeyan Anbarasan, www.f5debug.net ". You inform the third party that these conditions apply to him/her and that he/she must comply with them.

About Author: Karthikeyan Anbarasan, Microsoft MVP (Most Valuable Professional) in ASP.NET/IIS Architecture. He is the Founder and Chief Editor of the www.f5debug.net website and has authored books on Windows Phone and Business Intelligence(SSIS). He is also a Passionate Speaker and a Blogger on Microsoft Technologies.

You can Join Me On: Facebook, Twitter, Google Plus, LinkedIn

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Recent Posts

Random Posts

Most Viewed

URL Shortner

Create your own short urls!!!

Site Counter

free counters

Disclaimer

This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet. I have documented my personal experience on this blog.

Protected by Copyscape Web Plagiarism Finder

Site Meter