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

Which of these techniques results in performance improvement of a web site?

NOTE: This is objective type question, Please click question title for correct answer.
How can you configure the mobile devices for Session State?

NOTE: This is objective type question, Please click question title for correct answer.
How can you test whether the Windows user is authenticated?

It can be done by using this code snippet

Write it in an event handler (Page_Load for example)

   if (User.Identity.IsAuthenticated == true)

{
Response.Write(User.Identity.Name + "---" + "authenticated");
}


It will display the Windows user name if authenticated
What is RedirectPermanent?

It is a method of the Response object and has been introduced in ASP.NET 4.0.

It redirects permanently to the target page and returns a code 301.

Response.Redirect, which performed temporary redirection to the target page and returned code 302.

This effect can be viewed in search engines.

Example:
We are in Default.aspx and use Response.Redirect("Default2.aspx");
Both pages exist:
If RedirectPermanent is used,Default.aspx will no longer exist
Can we save ViewState on the server side?

Yes, we can save ViewState on the server side.

But we have to override two virtual methods known as

LoadPageStateFromPersistenceMedium() and SavePageStateToPersistenceMedium() of System.Web.UI.Page class on the .aspx page.

protected internal virtual void SavePageStateToPersistenceMedium(
Object state)
{

}

protected override Object LoadPageStateFromPersistenceMedium()
{

}
//Override these 2 methods on web page.
How can you prevent data to be removed from Cache when memory becomes low?

Use the DisableMemoryCollection property of the CacheSection class.

// Set the DisableMemoryCollection property to true.

CacheSection.DisableMemoryCollection = true;
we can also set through web.config file
example:
<configuration>
<system.web>
<caching>
<cache disableMemoryCollection="true"/>
</caching>
</system.web>
</configuration>

CacheSection class belongs to System.Web.Configuration name space.
Where does caching of a UserControl occur?

NOTE: This is objective type question, Please click question title for correct answer.
Can you cache a web page on the basis of stylesheets?

Yes, we can cache a web page on the basis of stylesheets.

Use the VaryByCustom attribute in the OutputCachde directive
example:
<%@ OutputCache Duration="1000" VaryByParam="None" VaryByCustom="css" %>
What is "Has File" property for a FileUpload control?

The "Has File" property is a property which is used for checking whether the file is posted or not i.e selected or not.
This property returns the value true if the file is posted i.e selected and this returns false if the file is not posted.
What is "Content Type" for a FileUpload control?

This is a property which is used for checking the format of the posted file.

The formats can be
1) text/plain: It specifies a plain text file (.txt file).
2) text/xml: It specifies xml file.
3) application/word: It specifies a document file.
4) image/gif: It specifies a gif format image.

Like this we can mention the different dot extension properties.
In which situations would you use HTML controls in an ASP.NET web site?

These are the situations:

1)If any .html page is used in the ASP.NET Web Site.
Only HTML controls can be used in this case.
2) Designing: Table Control, Horizontal Rule
Table Control: acts as a container for other control.
Horizontal Rule: for drawing horizontal Lines.
3) If State Management is not required in a given page.
4) Javascript code that needs to be executed without posting the page back to the server.example: sum of 2 numbers by clicking an HTML button and displaying the result in an alert.
What is Event Bubbling?

The concept of calling parent event from child event.
For example, Let us take a GridView Control. GridView control consists of several events like row edit,update. We can edit a particular row of a gridview control by raising row edit event. The reslt of that row edit event effects to the gridview control data. Hence this concept is called Event Bubbling...
Difference between Response.Write() and Respons.WriteFile()

Response.Write():

It writes information to the Http Response and can be used to display strings in the output.

example: Response.Write("welcome");


Response.WriteFile():

Writes the specified file directly to an HTTP response output stream.

example:- Response.WriteFile("demo.txt");
You make changes to the Web.Config file? How will they affect the web application?

NOTE: This is objective type question, Please click question title for correct answer.
After which of these events, ViewState of a Page is saved?

NOTE: This is objective type question, Please click question title for correct answer.
Which of these state management techniques data can be seen using Tracing?

NOTE: This is objective type question, Please click question title for correct answer.
Which of these components have the DefaultButton property?

NOTE: This is objective type question, Please click question title for correct answer.
How does the LinkButton post the form back to the server?

It uses JavaScript internally and is rendered as HyperLink.

example: if a LinkButton with ID LinkButton1 is there and its Text is Click, then
the HTML rendered is as follows.

<a id="LinkButton1" href="javascript:_doPostBack('LinkButton1',' ')">Click</a>

javascript:_doPostBack() method is responsible for posting the form and the data
back to the server
What is Site Navigation?

The Site Navigation system have the quality to define the entire site in an XML file that is called sitemap . After defining the sitemap you can use it out programatically using the sitemap class in your application.
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