You are on page 1of 20

What is the difference between login controls and Forms authentication?

• Forms authentication can be easily implemented using login controls without writing
any code.
• Login control performs functions like prompting for user credentials, validating them
and issuing authentication just as the FormsAuthentication class.
• However, all that’s needs to be dne is to drag and drop the use control from the tool
box to have these checks performed implicitly.
• The FormsAuthentication class is used in the background for the authentication ticket
and ASP.NET membership is used to validate the user credentials.

What is the difference between login controls and Forms authentication?

Login control provides form authentication. If we implement for authentication through form
authentication then we do it through code. On the other hand, login control allows the easy
implementation on the basis of form authentication without writing much of code. Underneath
the control, the class used for login control is also FormAuthentication class. So instead of
creating your own set of user credential validations and issuing of authentication ticket, it is
simpler to use a normal login control.

What is Fragment Caching in ASP.NET?

• Fragment caching refers to the caching of individual user controls within a Web
Form.
• Each user control can have independent cache durations and implementations of
how the caching behavior is to be applied.
• Fragment caching is useful when you need to cache only a subset of a page.
• Navigation bars, header, and footers are good candidates for fragment caching.

ASP.NET - What is Fragment Caching in ASP.NET? - June 04, 2009 at 15:00 PM


by Shuchi Gauri

Fragment caching allows to cache specific portions of the page rather than the whole page. It
is done by implementing the page in different parts by creating everything in form of user
controls and caching each user control individually.

What is partial classess in .net?

When there is a need to keep the business logic separate from the User Interface or when
there is some class which is big enough to have multiple number of developers implement the
methods in it, the class can be separated and written in different files as partial class.

The keyword partial must appear in each class.

//syntax for C#
Public partial class MyPartialClass1
{
//code
}

// this code could be in file1


Public partial class MyPartialClass1
{
//code
}
// this code could be in file2

ASP.NET - What is partial classess in .net? - June 04, 2009 at 18:00 PM by Shuchi
Gauri

Partial classes allow us to divide the class definition into multiple files (physically). Logically,
all the partial classes are treated as a single file by the compiler.

Explain how to pass a querystring from an .asp page to aspx page.

Consider the following URL:

http:// localhost/form.aspx?param1=career&param2=ride

This html addresses use QueryString property to pass values between pages.

From the URL above the information obtained is:

form.aspx: which is the destination page for your browser.


Param1 is the first parameter, the value of which is set to career
Param2 is the first parameter, the value of which is set to ride

The ‘?’ marks the beginning of the QueryString


‘&’ is used as a separator between parameters.

private void formButtonSubmit_Click(object sender, System.EventArgs e)


{
Response.Redirect("form.aspx?Param1=" +
this.formTextfieldParam1.Text + "&Param2=" +
this. formTextfieldParam2.Text);
}

The above code is a submit button event handler and it sends the values of the query string to
the second page.

The following code demonstrates how to retrieve these valus on the second page:
private void Page_Load(object sender, System.EventArgs e)
{
this.form2TextField1.Text = Request.QueryString["Param1"];
this. form2TextField2.Text = Request.QueryString["Param2"];
}

You can also use the following method to retrieve the parameters in the string:

for (int i =0;i < Request.QueryString.Count;i++)


{
Response.Write(Request.QueryString[i]);
}
ASP.NET - How to pass a querystring from an .asp page to aspx page - June 04, 2009
at 15:00 PM by Shuchi Gauri

From HTML in asp page: <a href="abc.aspx?qstring1=test">Test Query String</a>


From server side code: <%response.redirect "webform1.aspx?id=11"%>

What is a ViewState?

• If a site happens to not maintain a ViewState, then if a user has entered some
information in a large form with many input fields and the page is refreshes, then the
values filled up in the form are lost.
• The same situation can also occur on submitting the form. If the validations return an
error, the user has to refill the form.
• Thus, submitting a form clears up all form values as the site does not maintain any
state called ViewState.
• In ASP .NET, the ViewState of a form is maintained with a built-in state management
technique keeps the state of the controls during subsequent postbacks by a particular
user.
• The ViewState indicates the status of the page when submitted to the server. The
status is defined through a hidden field placed on each page with a <form
runat="server"> control.
<input type="hidden" name="__VIEWSTATE" value="CareerRide">
• The ViewState option can be disabled by including the directive <%@ Page
EnableViewState="false"%> at the top of an .aspx page
• If a ViewState of a certain control has to be disabled, then set
EnableViewState="false".

ASP.NET - What is ViewState? Explain its benefits and limitations - May 08, 2009 at
17:40 PM by Shuchi Gauri

What is ViewState? Explain its benefits and limitations.

Viewstate is used to maintain or retain values on postback. It helps in preserving a page.


Viewstate is internally maintained as a hidden field in encrypted form along with a key.

Advantages:

i) No server resources.
ii) Viewstate ensures security because it stores the data in encrypted format.
iii) Viewstates are simple. They are used by enabling or disabling the viewstate properties.
iv) It is based on the wish of developer that they want to implement it at the page level or at
control level.

Disadvantages:

i) If large amount of data is stored on the page, then page load might cause a problem.
ii) Does not track across pages. Viewstate information does not automatically transfer from
page to page.

ASP.NET - What is ViewState? - May 20, 2009 at 10:10 AM

What is Viewstate?
Viewstate is the mechanism that automatically saves the values of the page's items just
before rendering the page. It stores items added to a page’s ViewState property as hidden
fields on the page.

Difference between src and Code-Behind

With the ‘src’ attribute, the source code files are deployed and are compiled by the JIT as
needed.
Though the code is available to everyone with an access to the server (NOT anyone on the
web), this method is preferred as it does away with the compilation of the DLLs.

‘CodeBehind’ attribute just has the VS.NET associate the code file with the aspx file. This is
necessary since VS.NET automates the pre-compiling that is harder by hand.

Due to this the ‘Src’ attribute is done away with having only a DLL to be deployed enhancing
the protection level even though it can be decompiled.

ASP.NET - Difference between src and Code-Behind. - June 04, 2009 at 15:00 PM
by Shuchi Gauri

Src: is a way mention the name of the code-behind class to dynamically compile on the
request for a page.

Code-behind: is the logic written behind the UI design file. It specifies the name of the
compiled file that contains the class. Code-behind attribute is only used for.Net.

What is the difference between URL and URI?

A URL (Uniform Resource Locator) is the address of some resource on the Web. A resource
is nothing but a page of a site. There are other type of resources than Web pages, but that's
the easiest conceptually.

A URI is a unique identifier to usually a namespace.


Though it looks like a URL but it doesn’t have to necessarily locate any resource on the web.

URI is a generic term. URL is a type of URI.

ASP.NET - What is the difference between URL and URI? - June 04, 2009 at 15:00 PM
by Shuchi Gauri

URI - Uniform Resource Identifier: it’s a string and its responsibility is to identify a resource by
meta-information. It gives information about only one resource.

URL - Uniform Resource Locator: identifies the resource on the net and tells it is obtainable
using what protocols.

What is the Pre-Compilation feature of ASP.NET 2.0?

Previously, in ASP.NET, the pages and the code used to be compiled dynamically and then
cached so as to make the requests to access the page extremely efficient. In ASP.NET 2.0,
the pre-compilation feature is used with which an entire site is precompiled before it is made
available to users.
There is a pre-defined folder structure for enabling the pre-compilation feature:

• App_Code: stores classes


• App_Themes: stores CSS files, Images, etc.
• App_Data: stores XML files, Text Files, etc.
• App_GlobalResources: stores all the resources at global level E.g. resx files, etc
• App_LocalResources: stores all the resources at local/Page level

ASP.NET - What is the Pre-Compilation feature of ASP.NET 2.0? - June 04, 2009 at
15:00 PM by Shuchi Gauri

It is a process where things that can be handled before compilation are prepared in order to
reduce the deployment time, response time, increase safety. It’s main aim to boost
performance.

It also helps in informing about the compilation failures.

During development, it allows you to make changes to the web pages and reuse it using the
same web browser to validate the changes without compiling the entire website.

During deployment, it generates the entire website folder structure in the destination. All the
static files are copied to the folder and bin directory would later on contain the compiled dll.

How can we create custom controls in ASP.NET?

Custom controls are user defined controls. They can be created by grouping existing controls,
by deriving the control from System.Web.UI.WebControls.WebControl or by enhancing the
functionality of any other custom control. Custom controls are complied into DLL’s and thus
can be referenced by as any other web server control.

Basic steps to create a Custom control:

1. Create Control Library


2. Write the appropriate code
3. Compile the control library
4. Copy to the DLL of the control library to the project where this control needs to be used
5. The custom control can then be registered on the webpage as any user control through the
@Register tag.

What is an application domain?

It's a way in CLR to maintain a boundary between various applications to ensure that they do
not interfere in working of any other application. CLR acts as a mini operating system where a
single process may have various application domains.

ASP.NET interview questions- March 13, 2009 at 15:20 PM by Amit Satpute

Explain the concepts of application domain.

• An operating system process can have many ongoing application domains.


Application Domains keep an application separate.
• All objects created within the same application scope are created within the same
application domain.
• Multiple application domains can exist in a single operating system process,
• Distinct memory address space allocation by the OS is effective but expensive and it
does not satisfy to the numbers required for large web servers.
• However, the CLR isolates an application by managing the memory use of code
running within the application domain due to which the code cannot access memory
outside the boundaries of the domain.

Explain the two different types of remote object creation mode in .NET.

Ways in which object can be created using Remoting: -

SAO Server Activated Object (call mode): lasts the lifetime of the server. They are
activated as SingleCall/Singleton objects. It makes objects stateless. A SingleCall object gets
created for each request by client and A Singleton object is created once on the server and is
shared by all the clients.

CAO (Client Activated Objects): CAO creates stateful objects. The object creation request
is based on the request by client side. Therefore, the lifetime is based on client and not
server. Single instance of object is created for every call.

Describe SAO architecture of Remoting.

Remoting has at least three sections:-

1. Server
2. Client: This connects to the hosted remoting object
3. Common Interface between client and the server .i.e. the channel

Remoting takes an indirect approach to application domain communication by creating proxy


objects. Communication is performed as below:

a. When a client object wants to create an instance of the server object, the remoting system
at the client creates a proxy of the server object. The proxy object is at the client but behaves
exactly like the remote object i.e. the server object.

b. The proxy passes the call information to the remoting system on the client. Client remoting
system then sends the information to the remoting system on the server which then invokes
the actual method on the server object. The remoting system on the server then passes the
result information back to the client remoting system.

c. The client remoting system returns the results to the client object through the proxy

Explain Singleton architecture of Remoting.

Singleton architecture is to be used when all the applications have to use or share same data.

Define LeaseTime, SponsorshipTime, RenewOnCallTime,


LeaseManagePollTime.
Terms related to lifecycle of a remoting object.

The LeaseTime property protects the object so that the garbage collector does not destroy it
as remoting objects are beyond the scope of the garbage collector. Every object created has
a default leasetime for which it will be activated. Once the leasetime expires, the object is
eligible again for garbage collector and is eventually destroyed. Default value is 5 minutes.

Even though the leasetime of an object has expired, there still may be clients who would still
need the remoting object on the server. In such cases the leasemanager keeps a track of
such clients and asks them if they need the object and are ready to extend or sponsor the
object to extend its existence. This is done through SponsorshipTime property, which is then
based on the sponsor.

The RenewOnCallTime property defines the duration for which a remoting object's lease is
extended if a sponsor is found. The default value is 2 minutes.

The LeaseManager class has a property PollTime, which defines the frequency at which the
LeaseManager polls the leases. Default is 10 seconds

Briefly explain how to specify remoting parameters using config files.

The remoting parameters can be specified through both programming and in config files. All
the settings defined in config files are placed under <system.runtime.remoting>

<application> is placed under system.runtime.remoting but the name attribute of application


tag specifies if the parameter is for server or client. RemotingConfiguration.Configure is used
to access the configuration keys for remoting properties.

What is marshalling? Explain types of marshalling.

Marshaling is a process of transforming or serializing data from one application domain and
exporting it to another application domain.

Two types of marshalling

• Marshal by value: a copy of an object is created by the server and is passed and
used by the client.
• Marshal by reference: the client creates a proxy to access the object.

What is ObjRef object in remoting?

ObjRef is a searializable object returned by Marshal() that knows about location of the remote
object, host name, port number, and object name.

Explain the steps of acquiring a proxy object in web services.

• Client communicates to UDI node to retrieve a list of available web services that the
client has access to.
• Every service listed has a URI pointing to the service's DISCO or WSDL document,
which is needed to access the webservice and its 'webmethod" methods.
• After interpreting the DISCO document, follow the URI for the WSDL document
related to the chosen webservice.
• Client then adds and parses the WSDL document and creates a proxy object which
can then communicate with Webservice and access its "webmethod" methods

Explain the steps to create a web services and consume it.

Steps to create and consume a webservice

Creation:

• a. Create a new website by selecting "ASP.NET Web Site" and giving it a suitable
name.
• b. service.cs file appears inside the solution with a default webmethod named as
"HelloWorld()"
• c. Right click on the webservice project and add a web reference instead of adding a
normal reference.
• d. A window appears that displays a list of webservices knows to the solution.
• e. Click on "Webservices in this solution"
• f. a search progress bar appears and
• g. Select the service that appears in the list
• h. progress bar appears once again.
• i. web method appears on the screen
• j. Click on "Add reference" button. This would add localhost
• k. solution would have App_WebReference folder

Consumption or Usage:

• a. Add a UI (.aspx) to the webservice project


• b. Add a button and a label to the form
• c. Double click the button to see the click event of the button
• d. Create an object of type service localhost.serviceName
• e. Write code to display the value returned by the webmethod on the label
• f. Execute the solution by setting the added aspx as the startpage.
• g. click on the button and the message "Hello World" would be displayed on the label

Explain the difference between cache object and application object.

Application Object: Application variable/object stores an Object with a scope of availability


of the entire Application unless explicitly destroyed.

Caching Object: The lifetime of cache is throughout the lifetime of an application or is based
upon timeouts

What is Scavenging?

A process where items are removed from cache in order to free the memory based on their
priority. A property called "CacheItemPriority" is used to figure out the priority of each item
inside the cache. This priority property is set when an item is added to the cache.

Define Caching in ASP.NET.

Caching technique allows to store/cache page output or application data on the client. The
cached information is used to serve subsequent requests that avoid the overhead of
recreating the same information. This enhances performance when same information is
requested many times by the user.

Advantages of Caching

It increases performance of the application by serving user with cached output.


It decreases server round trips for fetching data from database by persisting data in the
memory.
It greatly reduces overhead from server resources

What are the types of Caching in ASP.NET?

Caching in ASP.NET can be of the following types


Page Output Caching
Page Fragment Caching
Data Caching

ASP.NET - types of caching - Dec 25, 2009 at 19:55 PM by Nishant Kumar

Explain in brief each kind of caching in ASP.NET.

Page Output Caching


This type of caching is implemented by placing OutputCache directive at the top of the .aspx
page at design time.
For example:
<%@OutputCache Duration= "30" VaryByParam= "DepartmentId"%>

The duration parameter specifies for how long the page would be in cache and the
VaryByParam parameter is used to cache different version of the page.
The VaryByParam parameter is useful when we require caching a page based on certain
criteria.

Page Fragment Caching


This technique is used to store part of a Web form response in memory by caching a user
control.

Data Caching
Data Caching is implemented by using Cache object to store and quick retrieval of application
data.
Cache object is just like application object which can be access anywhere in the application.
The lifetime of the cache is equivalent to the lifetime of the application. .

Describe exception handling in ASP.NET.

Exception handling correct unusual occurrences and prevent application from getting
terminated. You can use Try(try) block and Error event procedures to handle exceptions.

Define Exception handling in ASP.NET.

Exceptions or errors are unusual occurrences that happen within the logic of an application.
The CLR has provided structured way to deal with exceptions using Try/Catch block.
ASP.NET also supports exception handling through server events such as Page_Error and
Application_Error events.
What are the ways of handling exceptions in ASP.NET?

There are three ways to handle exceptions in ASP.NET


Try/catch/finally block.
Using Events like Page_Error and Application_Error
Using Custom error page

Explain Try/catch block of exception handling.

You can enclose code in Try/Catch/Finally block. You can catch all exceptions in the catch
block. The third part of this block is finally. It is executed irrespective of the fact that an
exception has been raised.

Define Error Events.

ASP.NET supports events that occur when any unhandled exception occurs in an application.
These events are called as Error Events.

ASP.NET provides two such events to handle exceptions

• Page_Error : This is page event and is raised when any unhandled exception occur in
the page.
• Application_Error: This is application event and is raised for all unhandled exceptions
in the ASP.NET application and is implemented in global.asax

The Error events have two methods to handle the exception:

• GetLastError: Returns the last exception that occurred on the server.


• ClearError: This method clear error and thus stop the error to trigger subsequent error
event

Why is exception handling important for an application?

Exception handling is used to prevent application from being stuck due to unusual
occurrences. If the exceptions are handled properly, the application will never get terminated
abruptly.

When can you use tracing with exception handling?

You can use tracing with exception handling to log unanticipated exception to the trace log.
The log file can be used to diagnose unanticipated problems and thus can be corrected

Difference between authentication and authorization.

Authentication is the process of verifying the identity of a user.

Authorization is process of checking whether the user has access rights to the system.

Authorization is the process of allowing an authenticated user access to resources.

Authentication always proceeds to Authorization.


What is impersonation in ASP.NET?

By default, ASP.NET executes in the security context of a restricted user account on the local
machine.

However, at times it becomes necessary to access network resources which require


additional permissions.

This can be done away with using impersonation. ASP.NET can then execute the request
using the identity of the client making the request.

ASP.NET can also impersonate a specific account you specify in web.config.

What is impersonation in ASP.NET?

Impersonation is a technique to access application resources using the identity of some other
user.

By default, Impersonation is off

To enable impersonation:

<identity impersonate="true" userName="domain name\username" password="password"/>

What is event bubbling in .NET?

The passing of the control from the child to the parent is called as bubbling. Controls like
DataGrid, Datalist, Repeater, etc can have child controls like Listbox, etc inside them. An
event generated is passed on to the parent as an ItemCommand.

Describe how the ASP.NET authentication process works.

ASP.NET runs inside the process of IIS due to which there are two authentication layers
which exist in the system.

First authentication happens at the IIS level and the second at ASP.NET level per the
WEB.CONFIG file.

Working:

At first, IIS ensures that the incoming request is from an authenticated IP address.
Otherwise the request is rejected.

By default IIS allows anonymous access due to which requests are automatically
authenticated.

However, if this is changed, IIS performs its own user authentication too.

ASP.net checks if impersonation is enabled if a request is passed to ASP.net by an


authenticated user. If it is enabled, ASP.net acts itself as an authenticated user else it acts
with its own configured account.
Finally the OS resources are requested by the identity obtained from previous step.
The user is granted the resources if the authentication is successful else the resources are
denied.

Resources can include ASP.net page, code access security features to extend authorization
step to disk files, registry keys, etc.

What is Authentication in ASP.NET?

The process of identifying a user through the use of an ID and a password is known as
Authentication.

The ASP.Net authentication providers are as follows:

Windows Authentication Provider:


It is in conjunction with Microsoft Internet Information Services (IIS) authentication to secure
ASP.NET applications

Forms Authentication Provider


It is an application-specific login form which performs authentication using user code.

Passport Authentication provider:


It is a centralized authentication service provided by Microsoft that offers a single login and
core profile service for member sites.

Explain the ways of authentication techniques in ASP.NET

Selection of an authentication provider is done through the entries in the web.config file for an
application.

The modes of authentication are:

<authentication mode=”windows”>
<authentication mode=”passport”>
<authentication mode=”forms”>

Custom authentication needs installation of ISAPI filter in IIS. It compares incoming requests
to a list of source IP addresses and a request is considered to be authenticated if it comes
from an acceptable address.

Explain the various authentication mechanisms in ASP.NET.

ASP.NET supports 3 authentication mechanisms:

a. Windows Authentication: This is used for an intranet based application. Used to


authenticate domain users within a network. By default windows authentication is used.

b. Form Authentication: It’s a custom security based on roles and user accounts created
specifically for an application.

c. Passport Authentication: This is based on hotmail passport account.


Windows authentication.

If windows authentication mode is selected for an ASP.NET application, then authentication


also needs to be configured within IIS since it is provided by IIS.

IIS provides a choice for four different authentication methods:


Anonymous: IIS doesn’t perform any authentication. All are allowed to access the ASP.NET
application.

Basic: users must provide a windows username and password to connect. This information is
plain text which makes this mode insecure.

Digest: Users need to provide a password which is sent over the network. However in this
case the password is hashed. It also requires that all users be using IE 5 or later versions.

Windows integrated: passwords are not sent over the network. The application uses either the
Kerberos or challenge/response protocols authenticate the user. Users need to be running IE
3.01 or later.

Passport authentication

Passport authentication provides authentication using Microsoft’s passport service.


If passport authentication is configured and users login using passport then the authentication
duties are off-loaded to the passport servers.

Passport uses an encrypted cookie mechanism to indicate authenticated users. The passport
users are considered authenticated while the rest are redirected to the passport servers to log
in, after which they are redirected back to the site.

Passport Software Development Kit can be downloaded and installed http://


msdn.microsoft.com/library/default.asp?url=/downloads/list/websrvpass.aps.

Forms authentication

Using form authentication, ones own custom logic can be used for authentication.

ASP.NET checks for the presence of a special session cookie when a user requests a page
for the application. Authentication is assumed if the cookie is present else the user is
redirected to a web form.

Explain how authorization works in ASP.NET.

ASP.NET impersonation is controlled by entries in the applications web.config file.

Though the default setting is no impersonation, it can be explicitly set using:

<identity impersonate=”false”/>

With ASP.NET won’t perform any authentication and would run with its own privileges. The
default is an unprivileged account named ASPNET. It can be changed a setting in the
processModel section of the machine.config file.
Disabling impersonation runs the entire request in the context of the account running
ASP.NET (ASPNET account or the system account).

The second possible setting is to turn on impersonation.


<identity impersonate =”true”/>

Here, ASP.NET takes on the identity IIS passes to it. If anonymous access is allowed in IIS,
then the IUSR_ComputerName account will be impersonated otherwise ASP.NET will take
the authenticated user credentials and make requests for resources.

A particular identity can be specified to use all authenticated requests as:


<identity impersonate=”true” username=”DOMAIN\username” password=”password”/>

With this, the requests are made as the specified user. The password is assumed to be
correct. The drawback is that you must embed the user’s password in the web.config file in
plain text which is a security risk.

Authorization in ASP.NET - April 30, 2009 at 18:30 PM by Amit Satpute

What is Authorization in ASP.NET?

Usually after a user is authenticated by means of a login, the process of authorization is


followed where the decision is made whether a user should be granted access to a specific
resource.

There are 2 ways to authorize access to a given resource:

URL authorization:

URL authorization is performed by the UrlAuthorizationModule


It maps users and roles to URLs in ASP.NET applications.

File authorization:

File authorization is performed by the FileAuthorizationModule.


It checks the access control list of the .aspx or .asmx handler file to determine whether a user
should have access to the file.

Difference between Datagrid, Datalist and repeater

Similarities:

They are all ASP.NET data Web controls.

They have common properties like

DataSource Property
DataBind Method
ItemDataBound
ItemCreated
When the DataSource Property of a Datagrid is assigned to a DataSet then each
DataRow present in the DataRow Collection of DataTable is assigned to a
corresponding DataGridItem.

Difference:

Datagrid
The HTML code generated has an HTML TABLE element created for the particular DataRow
and is a tabular representation with Columns and Rows. Datagrid has a in-built support for
Sort, Filter and paging the Data.

Datalist
An Array of Rows and based on the Template Selected and the RepeatColumn
Property value The number DataSource records that appear per HTML

Repeater Control
The Datarecords to be displayed depend upon the Templates specified and the
only HTML generated accordingly. Repeater does not have in-built support for
Sort, Filter and paging the Data.

Datagrid, Datalist and repeater in ASP.NET - June 07, 2009 at 10:30 AM by Shuchi
Gauri

Difference between Datagrid, Datalist and repeater

Datagrid: For displaying data in an HTML <table>.i.e. DataGrid displays each


DataSource record as a row in an HTML <table>, and each field as a column in
said table. No matter what one record will occupy an entire row. However, it has
max features, like paging and sorting which are much easier to implement in
datagrid with minimal coding. DataList: Highly customized layout.You can display
multiple records in a single row. has advanced features and is much more
customizeabale than the datagrid. Is bidirectional. Repeater:it has only a subset
of the DataList's template options. Provides the maximum amount of flexibility
over the HTML produced. Repeater is a good choice if you need to display your
data in a format different than an HTML <table>. It needs a lot of coding to add
editing, sorting and paging features.

What are the events in GLOBAL.ASAX file in ASP.NET? - March 31, 2009 at 18:30 PM
by Amit Satpute

What are the events in GLOBAL.ASAX file?

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

What are the events in GLOBAL.ASAX file in ASP.NET? - March 31, 2009 at 18:30 PM
by Amit Satpute

What are the events in GLOBAL.ASAX file?

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

What are different IIS isolation levels supported in ASP.NET?

IIS has three level of isolation:-

LOW (IIS process):- In this main IIS process and ASP.NET application run in same process
due to which if one crashes, the other is also affected.

Medium (Pooled):- In Medium pooled scenario the IIS and web application run in different
process.

High (Isolated):-In high isolated scenario every process is running is there own process. This
consumes heavy memory but has highest reliability

Difference between Gridlayout and FlowLayout.

GridLayout provides absolute positioning for controls placed on the page.

FlowLayout positions items down the page like traditional HTML. This approach results in
pages that are compatible with a wider range of browsers.
What is AppSetting Section in “Web.Config” file?

Web.config file defines configuration for a webproject.

AppSetting section is used to set the user defined values. For e.g.: The ConnectionString
which is used through out the project for database connection.

<configuration>
<appSettings><BR><addkey="ConnectionString"value="server=xyz;pwd=www;database=test
ing" />
</appSettings>

AppSetting Section in ASP.NET - May 07, 2009 at 15:30 PM by Shuchi Gauri

What is AppSetting Section in “Web.Config” file?

AppSetting section in the configuration file is a section that allows us to keep configurable and
application wide settings (for e.g.: ConnectionString) that an application requires in order to
perform the tasks properly. This helps in easy maintenance and deployment of the
application.

Web.confg:
<appsettings>
<add key="ConnectionString" value="(your connection string)" />
</appsettings>

Code behind:
string strConnection = ConfigurationSettings.AppSettings["ConnectionString"];

Difference between Server.Transfer and response.Redirect.

Following are the major differences between them:-

Server.Transfer

• The browser is directly redirected to another page


• There is no round trip
• A Server transfer is possible within a website
• Information can be preserved in Server transfer through a parameter called
preserveForm

Response.Redirect

• The browser is requested to redirect to some other page through a message.


• There is a round trip.
• Response redirect is possible within two websites too.
• A state can be maintained in Response redirect but has a lot of drawbacks

ASP.NET Server.Transfer and Response.Redirect - March 13, 2009 at 15:20 PM by Amit


Satpute

List the difference between Server.Transfer and Response.Redirect.


Server.Transfer

The Transfer method transfers from inside of one ASP page to another ASP page.
Transfer passes the context information to the called page.
The state information that has been created for an ASP page gets transferred to the other
ASP page which comprises of objects and variables within an Application or Session scope,
and all items in the Request collections.

Response.Redirect

The redirect message issues HTTP 304 to the browser and causes browser to go to the
specified page. There is round trip between client and server.
Redirect doesn’t pass context information to the called page

What is event bubbling in .NET?

The passing of the control from the child to the parent is called as bubbling. Controls like
DataGrid, Datalist, Repeater, etc can have child controls like Listbox, etc inside them. An
event generated is passed on to the parent as an ItemCommand

You might also like