Showing posts with label Difference between Server control and User Control and Custom control. Show all posts
Showing posts with label Difference between Server control and User Control and Custom control. Show all posts

Tuesday, 4 April 2017

.Net Interview Question Answer


Global.asax :

1. Global.asax is basically ASP.NET Application file.
2. It’s a place to write code for Application-level events such as Application start, 
    Application end,Session start and end, Application error etc.
    raised by ASP.NET or by HTTP Modules.
3. It is  file resides in the root directory of an ASP.NET-based application. 
4. It is  file is parsed and dynamically compiled by ASP.NET.
5.The Global.asax file itself is configured so that any direct URL request for 
    it is automatically rejected; external users cannot download or view the code written within it.

The Global.asax contains two types of events those are

1. Events which are fired for every request
2. Events which are not fired for every request

* Events which are fired for every request:

A. Application_BeginRequest() ​:
     This event raised at the start of every request for the web application.
B. Application_AuthenticateRequest​() :
     This event rose just before the user credentials are authenticated. 
     We can specify our own authentication logic here to provide custom authentication.
C. Application _AuthorizeRequest() ​:
    This event raised after successful completion of authentication with user’s credentials. 
    This event is used to determine user permissions. 
    You can use this method to give authorization rights to user.
 D. Application_ResolveRequestCache()​ :
    This event raised after completion of an authorization request and this event used in 
    conjunction with output caching. 
    With output caching, the rendered HTML of a page is reused without executing its code.
 E. Application_AcquireRequestState()​ :
    This event raised just before session-specific data is retrieved for the client and is used to 
    populate Session Collection for current request.
 F. Application_PreRequestHandlerExecute()​ :
     This event called before the appropriate HTTP handler executes the request.
G. Application_PostRequestHandlerExecute()​ :
     This event called just after the request is handled by its appropriate HTTP handler.
H. Application_ReleaseRequestState()​ :
    This event raised when session specific information is about to serialized from the 
     session collection.
 I. Application_UpdateRequestCache()​ :
    This event raised just before information is added to output cache of the page.
 J. Application_EndRequest()​ :
    This event raised at the end of each request right before the objects released.

* Events which are not fired for every request

A. Application_Start()​ :
    This event raised when the application starts up and application domain is created.
B. Session_Start()​ :
   This event raised for each time a new session begins, This is a good place to put code 
    that is session-specific.
C. Application_Error()​ :
   This event raised whenever an unhandled exception occurs in the application. 
   This provides an opportunity to implement generic application-wide error handling.
D. Session_End()​ :
   This event called when session of user ends.
E. Application_End()​ :
   This event raised just before when web application ends.
F. Application_Disposed()​ :
  This event fired after the web application is destroyed and this event is used to reclaim 
   the memory it occupies.





x