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

Difference between Web Garden and Web Farm?

Web garden and web farms are asp.net applications that serve the purpose when the
user base of a web site increases considerably.

Web garden is a web application running on a single computer with multiple
processors but Web farm is a web application running on multiple servers. The
benefit of using this is, if one server crashes then other will work instantly.

For Web garden/Web Farm configurations, we have to set sessionState mode to
StateServer/SQLServer in the web.config file.

For Web Garden, we have to use
<processModel webGarden="true"/>
in Machine.Config file.

Web Farm is implemented using techniques like Net Work Load Balancing.
What is the use of AutoEventWireUp attribute?

The use of AutoEventWireUp attribute is to execute the code in the Page event
handlers like Init, Load etc.

In the earlier versions of ASP.NET that is (1.0/1.1), it was false by default.
If we will make it true, then the Page_Load() will fire two time. But from ASP.NET2.0
onwards, the default value for AutoEventWireUp attribute is true.
A theme can contain how many Default and Named skin for each control ?

A theme can contain only one Default Skin for each type of control. However, a
theme can contain as many Named skins as you can. Each Named Skin must have
a unique name.

Sample code:
TextBox.Skin:
<asp:TextBox SkinID="DashedTextBox" BorderStyle="Dashed" BorderWidth="5px" runat="server" /> 

<asp:TextBox BorderStyle="Double" BorderWidth="5px" runat="server"/>


ShowNamedSkin:
<%@ Page Language="C#" AutoEventWireup="true" 

CodeBehind="ShowSkin.aspx.cs" Inherits="DemoApp.ShowSkin" Theme="SimpleTheme" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Show Named Skin</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtFirstName" runat="server" SkinID="DashedTextBox">
</asp:TextBox>
<br /><br />
<asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>

What is the difference between Session.Abandon() and Session.Clear()?

Session.Abandon() will end current session by firing Session_End and in the next
request, Session_Start will be fire.

Session.Clear( ) just clears the session data without killing it. With session.clear
variable is not removed from memory it just like giving value null to this session.

Session ID will remain same in both cases, as long as the browser is not closed.
What is the Pages MaxPageStateFieldLength for?

When the MaxPageStateFieldLength property is set to a positive number, the view state sent to the client browser is broken into multiple hidden fields, and each field's value is less than the size specified in the MaxPageStateFieldLength property.

Setting the MaxPageStateFieldLength property to a negative number (the default) indicates that the view-state field should not be separated into chunks. Setting the MaxPageStateFieldLength to a small number may result in poor performance.

Set the value of the MaxPageStateFieldLength property in the pages element of the Web.config file.


<system.web>

<pages MaxPageStateFieldLength="2048" />
</system.web>
What attribute must be set on a validator control for the validation to work ?

NOTE: This is objective type question, Please click question title for correct answer.
Where is the default Session data is stored in ASP.Net?

NOTE: This is objective type question, Please click question title for correct answer.
What is the difference between application state and caching?

Application variable is the global variable specific to application but a caching variable is specific to page and time out. Application variables exist as long as the application is alive. Whereas the cache has the Property of timeout which allows us to control the duration of the Objects so cached.Another usefulness in caching is that we can define the way we cache our output since caching can be done in 3 ways - a) Full Page - defined in page directrive) Partial Page - Eg - .ascx control) Data / Programmatic caching. using the Properties of Cache object such as Cache.Insert .Caching variable is specific to page and time outApplication variable is the global variable specific to application. Application Object and Cached Object both falls under Server side State Management.Application object resides in InProc i.e. on the same server where we hosted our application.Cache Object resides on server side/ DownStream/Client Side.Application Object will be disposed once application will stop.Cache Object can be disposed using Time based cache dependency.Only one user can access Application Object at a time hence we have to lock it every time we modify it.
How do you turn off cookies in your site?

Use the Cookie.Discard Property which gets or sets the Discard flag set by server. When true this property instructs the client application not to save the cookie on the users hard disk when a session ends.

OR

It can be turned off by mentioning cookie state= false in Web.Config file.This will turn off session cookie.



Thanks and Regards
Akiii
What is .Net Remoting?

.NET Remoting is a mechanism for communicating between objects which are not in the same process. .NET remoting enables you to build widely distributed applications easily, whether application components are all on one computer or spread out across the entire world. It provides a number of services, including activation and lifetime support, as well as communication channels responsible for transporting messages to and from remote applications.

Refer this link,

http://www.codeproject.com/KB/IP/remotingchatsample.aspx
What is viewstate in ASP.NET ?

Viewstate object is used to persist data of variables across postbacks. In ASP.NET, a variable's value is assigned to a viewstate object and then this is passed as a hidden variable and then may be retrieved by a page after a postback. See the example below...

//Save the value in ViewState object before the PostBack

ViewState("SomeVar") = txtFirstName.text;


//Retrieve the value from ViewState object after the PostBack

String strFirstName = ViewState("SomeVar").ToString();


Note that Viewstate object's value is accessible only at page level. This means that if a viewstate is created at page1.aspx, then it may be used only within page1.aspx after the postback, and cannot be used by any other page.

Thanks and Regards
Akiii
Can we run asp.net application without WEB.CONFIG file ?

Yes, we can run an asp.net application without the WEB.CONFIG file. It means that the default configuration will be loaded from MACHINE.CONFIG file.
What is the difference between ASP and ASP.NET?

1. ASP is interpreted, ASP.NET is compiled.

2. Classic ASP uses a technology called ADO to connect and work with databases. ASP.NET uses the ADO.NET technology

3. ASP has Mixed HTML and coding logic where in asp.net html and coding part are separated by code behind files.

4. ASP.NET purely object oriented whereas ASP is partially object oriented.

5. For ASP No in-built support for XML whereas in ASP.NET full XML Support for easy data exchange.
is multiple inheritance possible in c#.net?

NOTE: This is objective type question, Please click question title for correct answer.
How to pass values from one page to another in asp.net?

In ASP.NET there are several methods to pass values between pages. For passing and storing values asp.net using State management techniques. There are different types of state management techniques are there. They are
Here I am Explaining 2 techniques,
1. Querystring,
2. Session,

QueryString
In QueryString , attaching the values with the URL of the page,
For Example,
Response.Redirect("OrganizationDetailsAM.aspx?ApplicationDetailsID=" + applicationDetailsID + "&ApplicationType=" + applicationType, false);

For retieving this value in the next page,
Request.QueryString["ApplicationDetailsID"]


Session

A session is defined as the period of time that a unique user interacts with a Web application.
For Example,

Session["Name"]=value;
For retrieving,

variable=session["Name"];
What is the last method called during the Web Forms Life Cycle ?

NOTE: This is objective type question, Please click question title for correct answer.
Which among the following is the common property in every Validation control ?

NOTE: This is objective type question, Please click question title for correct answer.
By default where the sessions ID's are stored ?

NOTE: This is objective type question, Please click question title for correct answer.
What is the difference between a Label and Literal control in asp.net ?

Both the Label and Literal controls allow you to specify some text which appears on a web page. The main difference between them is "Label" control display the text wrapped around in a span tag. On the contrary, literal control doesn't do anything like that. It just display a text without wrapping it with anything. For example:-

Suppose you have a label and a literal control in your aspx page :-
<asp:Label ID="label1" runat="server"></asp:Label>

<br />
<asp:Literal ID="literal1" runat="server"></asp:Literal>


Now, bind your controls with some text :-
label1.Text = "label text";

literal1.Text = "literal text";


When you execute the code, you will see this:-
<span id="label1">label text</span>

<br />
literal text


In the above output, we see that the label text is wrapped around a span tag and the literal text is simply putting a text in it.

Please, note that if you do not need styling then its better to use literal. But do remember, label control has much more properties than the literal control, so choose wisely.

I hope i have made myself clear. Any problem or error with the above, please let me know.

Thanks and Regards
Akiii
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