Question 221 – What are the Event available in Global.asax?
Events
|
Description
|
Application_Init | Fired when an application initializes or is first called. It’s invoked for all HttpApplication object instances. |
Application_Start | Fired when first instance of the HttpApplication class is created. It allows to create objects that are accessible by all HttpApplication instances. |
Session_Start | Fired when a new user visits the application Web site. |
Application_BeginRequest | Fired when an application request is received. It’s 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_AuthenticateRequest | Fired when the security module has established the current user’s identity as valid. Here, the user’s credentials have been validated. |
Application_Error | Fired when an unhandled exception is encountered within the application. |
Session_End | Fired when a user’s session times out, ends, or they leave the application Web site. |
Application_End | Fired when the last instance of an HttpApplication class is destroyed. It’s fired only once during an application’s lifetime. |
Question 222 – What is Caching in ASP.Net?
- Caching is a technique where we can store frequently used data and Web pages are stored temporarily on local hard disks for later retrieval.
- This technique improves the access time when multiple users access a Web site simultaneously or a single user accesses a Web site multiple times.
- Caching can occur on the client (browser caching), on a server between the client and the Web server (proxy / Reverse Proxy Caching), and on the Web server itself (page or data caching).
- We can classified caching location in 4 way
- Client Caching (Client Browser)
- Proxy Caching (In between Client and Server)
- Reverse Proxy Caching (In between Client and Server)
- Web Server Caching (Data Caching/ Page Output Caching)
Question 223 – What are the Types of Caching in ASP.Net?
- Page Output caching [Output caching ] – Is used to fetch information or data at page level. It is best used when the site is mainly static. Used by declaring the output page directive
- Fragment caching [Output caching ] – Is used to cache the structure level information. It is used when parts of pages change. For example: user control
- Data Caching – Is used to fetch the information of an application quickly based on the requirements.
Question 224 – How to cache different versions of the same page in ASP.Net?
- The ways to cache different versions on the same page using ASP.NET cache object is using OutputCache object. Three parameters of OutputCache, has 3 parameters:
- VarByParam: based on input parameters passed through HTTP POST/GET.
- VarByHeader: based on the page header content.
- VayByCustom: based on declaration of an attribute and overriding GetVaryByCustomString handler.
- VarByControl: varies with the value of properties of ASP objects.
Question 225 – What is a Fragment Cache in ASP.Net?
It is used to store user controls individually within a web form in cache instead of the whole web form as such. The idea is to simply have different cache parameters for different user controls.
control1: <%@ OutputCache Duration=”40″ VaryByParam=”none”%>
control2: <%@ OutputCache Duration=”60″ VaryByParam=”none”%>
If control1 and control2 exist on a single web form together, the values of control1 and control2 would be cached for different durations based on @OutputCache directive.
[ad]Question 226 – What are Resource Files in ASP.Net?
- A resource file is a XML file that contains the strings that we want to Translate into different languages.
- Can be updated dynamically so that user themselves can modify values in resource files once the application is deployed on the server without re-compiling the entire application itself.
- The resource file contains key / value pairs.
- Each pair is an individual resource.
- Key names are not case sensitive.
Question 227 – What are the Types of Resource Files available in ASP.Net?
There are two types of resources
- Local Resources
- Global Resources
Question 228 – What is a Local Resource File in ASP.Net?
- It is specific to a single Web page and used for providing versions of a Web page in different languages.
- It must be stored in App_LocalResources sub folder.
- It must be named in format <WebPageName> [.language / language and culture].resx.
Question 229 – What is a Global Resource File in ASP.Net?
- Global resource can be read from any page or code that is in the application.
- Global resource must be stored in App_GlobalResources at the root of the application.
Question 230 – What are the main tags in Web.Config file of ASP.Net application?
<authentication> – This element is used to verify the client’s identity when the client requests a page from the server. This is set at the application level. We have four types of authentication modes: “None”, “Windows”, “Forms”, and “Passport”.
<authorization> – The <authorization> tag controls client access to web page resources. This element can be declared at any level (machine, site, application, subdirectory, or page).
<authorization>
<allow users=”comma-separated list of users”
roles=”comma-separated list of roles”
verbs=”comma-separated list of verbs”/>
<deny users=”comma-separated list of users”
roles=”comma-separated list of roles”
verbs=”comma-separated list of verbs”/>
</authorization>
<allow>: Using this tag, we can control access to resources on the basis of the following verbs. In these attributes, we use symbols: ? and *.? means for anonymous users/resources, and * means for all users.
users: This contains the list of user names (comma separated) that are allowed to access the resources.
roles: This contains the list of roles (comma separated) that are allowed to access the resources.
verbs: This contains the list of HTTP verbs to which the action applies (comma separated). It is used to create a rule that applies to a specific type of HTTP request (GET, POST, HEAD, OR DEBUG).
<deny>: Using this tag, we can control access to resources on the basis of the following verbs:
users: This contains the list of users names (comma separated) that are denied access to the resources.
roles: This contains the list of roles (comma separated) that are denied access to the resources.
verbs: This contains the list of HTTP verbs to which the action applies (comma separated). It is used to create a rule that applies to a specific type of HTTP request (GET, POST, HEAD, OR DEBUG).
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.