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

What is a Monitor Object ?

While using Monitor Objects, we cannot run the code in other threads until the code in the synchronized code block has finished.
SyncLock and End SyncLock statements are provided in order to simplify access to monitor object.
what is the PageMethod in .net 2.0 ?

It is special type of web service that enables you to create method in page and expose it as a REST resource. It only work with page, not with user control.

Serialization technology used by PageMethod is WCFJSON serializer.

It allows to call server method without creating web service and incurring the overhead of page life-cycle.
How many different ways for store database connection string in asp.net ?

You can choose among the following locations for string database connection strings

1) web.config

2) Universal data link (UDL) file (only for OLEDB.Net data provider)

3) Window registry

4) Custom file

5) Com+ catalog
Which namespace has Threading ?

To implement threading, you have to use Systems.Threading namespace.
This namespace has all the classes related to implement threading.
To implement Threading in any of the .NET Applications, you have to import this namespace.
What is Thread.Sleep() in Threading ?

By calling this Thread.Sleep method, you can pause the Thread's execution.
This method takes an integer value which determines how long the thread should sleep.

Example:

Thread.CurrentThread.Sleep(1000)

You have to add two asp:Button controls for Policy and for Renewal.You add an ASP.NET skin file named default.skin to a theme. You need to create and use a separate style for the Policy button, and you must use the default style for the Renewal button. What should you do?

Add the following markup to default.skin
<asp:Button SkinID ="Policy"></asp:Button >
<asp:Button></asp:Button>
Use the following markup for the buttons in the ASP.NET page.
<asp:Button SkinID ="Policy">Help</asp:Button>
<asp:Button>Renewal</asp:Button>
What method do you use to explicitly kill a user session.

Session.Abandon() is used to kill user session explicitly.

Lets say there is a seesion of UserID in your page.

Example:
if (Object.Equals(Session["USERID"], null))

{
Session.Abandon();
}

What is CDATA section in XML ?

All the data is normally parsed in an XML.
But if you want to exclude some elements, you have to keep those elements in CDATA section.
What is XSL ?

XSL is used to transfer data from XML document to another document.
So it is a transformation document which can convert XML document to some other document.
For instance,you can apply XSL to XML and convert it to HTML document or CSV files.
What is element and attribute in XML ?

We can have a clear view about the element and attribute in an XML from the below example.

Example:

<invoice invnumber=1001></invoice>


In the above example, invoice is the element and invnumber is the attribute.
Which are the namespaces in .NET used for XML ?

"System.xml.dll" is the actual physical file which has the actual XML implementation.
Below are the commonly used namespaces:

System.Xml
System.Xml.Schema
System.Xml.XPath
System.Xml.Xsl
What is XSLT ?

XSLT is a rule based language which is used to transform XML documents into other file formats.
XSLT are nothing but generic transformation rules which can be applied to transform XML document to HTML,CS,Rich text,etc.
What does the Orientation property do in a Menu control ?

Orientation property of the Menu control is used to set the horizontal or vertical display of a menu on a Web page.
By default, the orientation is vertical.
What setting must be added in the configuration file to deny a particular user from accessing the secured resources ?

To deny a particular user form accessing the secured resources, you have to keep the following code in web.config file.

<authorization >

<deny users="username" />
</authorization>

Difference between Convert.ToString() and object.ToString()

object.ToString() give run time error if object value is null, whereas Convert.ToString(object) does not give any error in case of object value is null;

Example:
object obj=null;
string str=obj.ToTsirng(); //it will give run time error
string str1=Convert.ToString(obj); // it will run, not give any error
What’s the .NET collection class that allows an element to be accessed using a unique key?

HashTable class that allows an element to be accessed using a unique key.

Example:
 Hashtable ht = new Hashtable();

ht["mykey1"] = "My Value1";
ht["mykey2"] = "My Value2";
ht["mykey3"] = "My Value3";
ht["mykey4"] = "My Value4";

Response.Write(ht["mykey1"].ToString());

What is the difference between Response.Write() and Response.Output.Write() ?

Both the commands are used to display the output on the screen.

Response.Write() is used to display a single line output.

Response.Output.Write() is used to display a formatable output.

Example:

Response.Write("Hi");

Response.Output.Write("x={0},y={1},x,y");

What is the difference between Datalist and Repeater?

->Datalist supports multiple columns displaying and using repeat columns property
->Repeater doesn't support multiple columns display,no repeat columns property
->Datalist supports styles for formating templates data[headerstyle,...]
->Repeater is not providing styles
->Datalist renndering output[html content]will be slow compare with repeater.

Conclusion:
If the requirement can achieve using repeater and datalist,choose repeater for better performance.
What is Cookies?

Cookie is a small amount of memory used by webserver with client system.
* The cookie variables will be accesible across different web pages of website towards *client request.
* The important of cookies is storing presonal information of client system to reduce memory burden on server (or) identifying client for different requests.
Cookies are two types:
1.In Memory Cookie
2.Persistant Cookie
In Memory Cookie: The Cookie variable placed within browser process is called "In Memory Cookie"
Persistant Cookie: The Cookie placed on harddisk memory in client system is called "Persistant Cookie".
State Management in ASP.NET

State Management
Type of state management in ASP.NET
1.InProc(Where session objects stored wit in IIS server)
2.OutProc(Where session objects store out of the server
a.State Server(where session objects can store in different server)
b.SQL server(where session objects can store in SQL server)

This can be configure in web.config file .
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