ASP.NET Interview Questions and Answers (1544) - Page 3

How to get the authentication mode from web.config file programmatically at runtime?

Write following code.


System.Web.Configuration.AuthenticationSection section =

(AuthenticationSection)WebConfigurationManager.GetSection("system.web/authentication");
Label1.Text = section.Mode.ToString();


You will get the authentication mode set in your web.config file.
How to convert an Array into an ArrayList?

Lets say you have array of Person object and you are getting an it from LoadPersons() method of your object like this

Person[] myPersonArray = myPerson.LoadPersons();

Now, if you want to convert above array into an ArrayList just write like this

ArrayList myPersonList = ArrayList.Adapter(myPersonArray );
How to convert an ArrayList into an Array?

Lets say you have myPersonList as an ArrayList that has Person object. If you want to convert this ArrayList into array of your Person object, write like this.

Person[] personArray = (Person[])myPersonList.ToArray(typeof(Person));

Here you need to cast the object into its type.
What’s the difference between Response.Write() and Response.Output.Write()?

Response.Output.Write() allows you to write formatted output.
What’s a bubbled event?

When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.
What is different between WebUserControl and in WebCustomControl ?

Web user controls :- Web User Control is Easier to create and another thing is that its support is limited for users who use a visual design tool one gud thing is that its contains static layout one more thing a seprate copy is required for each application.
Web custom controls:- Web Custom Control is typical to create and gud for dynamic layout and another thing is it have full tool support for user and a single copy of control is required because it is placed in Global Assembly cache.
What is smart navigation?

* It eliminates the flash caused during navigation
* It persists element focus during postbacks
* It persists scroll position during postbacks between pages
* It retains the lasts page information in the history of the browser
What is CAS?

CAS is the part of the .NET security model that determines whether or not a piece of code is allowed to run, and what resources it can use when it is running. For example, it is CAS that will prevent a .NET web applet from formatting your hard disk. How does CAS work? The CAS security policy revolves around two key concepts - code groups and permissions. Each .NET assembly is a member of a particular code group, and each code group is granted the permissions specified in a named permission set. For example, using the default security policy, a control downloaded from a web site belongs to the 'Zone - Internet' code group, which adheres to the permissions defined by the 'Internet' named permission set. (Naturally the 'Internet' named permission set represents a very restrictive range of permissions.)
What is Code group?

Code groups represent collections of code and each code group has an associated set of permissions.
What event handlers can I include in Global.asax?

Application_Start,Application_End, Application_AcquireRequestState, Application_AuthenticateRequest, Application_AuthorizeRequest, Application_BeginRequest, Application_Disposed, Application_EndRequest, Application_Error, Application_PostRequestHandlerExecute, Application_PreRequestHandlerExecute,
Application_PreSendRequestContent, Application_PreSendRequestHeaders, Application_ReleaseRequestState, Application_ResolveRequestCache, Application_UpdateRequestCache, Session_Start,Session_End
How many types of cookies are there in ASP.NET ?

1. Single valued

request.cookies(”dotnetfunda”)=”Sheo”

2. Multi valued

request.cookies(”donetfunda”)(”uname”)=”MAJITH?
Difference between DropDownList.Items.Add and DropDownList.Items.Insert method

DropDownList.Items.Add method allows you to add new ListItem into the DropDownList. This item will be added as the last item of the DropDownList.

dropDownList.Items.Add(new ListItem("Default Panel", "0"));


DropDownList.Items.Insert method allows you to specify the index of the item within the DropDownList where you want to insert the ListItem.

dropDownList.Items.Insert(0, new ListItem("Default Panel", "0"));


Here Default Value will be added as the first item in the DropDown.
Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.

inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension),the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.
What does the "EnableViewState" property do? Why would I want it on or off?

It enables the viewstate on the page. It allows the page to save the users input on a form.
Can you give an example of what might be best suited to place in the Application_Start and Session_Start subroutines?

This is where you can set the specific variables for the Application and Session objects.
What Is The Difference Between ViewState and Session...?

ViewState persist the values of controls of particular page in the client (browser) when post back operation done. When user requests another page previous page data no longer available.

SessionState persist the data of particular user in the server. This data available till user close the browser or session time completes.
What does WSDL stand for?

Web Services Description Language.
How will you upload a file to IIS in Asp and how will you do the same in ASP.net?

First of all, we need a HTML server control to allow the user to select the file. This is nothing but the same old <input tag, with the type set to File, such as <input type=file id=”myFile” runat=server />. This will give you the textbox and a browse button. Once you have this, the user can select any file from their computer (or even from a network). Then, in the Server side, we need the following line to save the file to the Web Server.

myFile.PostedFile.SaveAs ("DestinationPath")

Note: The Form should have the following ENC Type
<form enctype="multipart/form-data" runat="server">
What is State management in ASP.NET?

State management is the process by which you maintain state and page information over multiple requests for the same or different pages.
There are 2 types State Management:

1. Client – Side State Management
This stores information on the client's computer by embedding the information into a Web page, a uniform resource locator(url), or a cookie. The techniques available to store the state information at the client end are listed down below:

a. View State – Asp.Net uses View State to track the values in the Controls. You can add custom values to the view state. It is used by the Asp.net page framework to automatically save the values of the page and of each control just prior to rendering to the page. When the page is posted, one of the first tasks performed by page processing is to restore view state.

b. Control State – If you create a custom control that requires view state to work properly, you should use control state to ensure other developers don’t break your control by disabling view state.

c. Hidden fields – Like view state, hidden fields store data in an HTML form without displaying it in the user's browser. The data is available only when the form is processed.

d. Cookies – Cookies store a value in the user's browser that the browser sends with every page request to the same server. Cookies are the best way to store state data that must be available for multiple Web pages on a web site.

e. Query Strings - Query strings store values in the URL that are visible to the user. Use query strings when you want a user to be able to e-mail or instant message state data with a URL.

2. Server – Side State Management
a. Application State - Application State information is available to all pages, regardless of which user requests a page.

b. Session State – Session State information is available to all pages opened by a user during a single visit.

Both application state and session state information is lost when the application restarts. To persist user data between application restarts, you can store it using profile properties.
How to check viewstate tampering

NOTE: This is objective type question, Please click question title for correct answer.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories