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

What is Cross Page Posting ?

By default, ASP.NET submits a form to the same page.
In cross-page posting, the form is submitted to a different page. This is done by setting the ‘PostBackUrl’ property of the button(that causes postback) to the desired page.
In the code-behind of the page, to which the form has been posted, use the ‘FindControl’ method of the ‘PreviousPage’ property to reference the data of the control in the first page.
How can you detect if a viewstate has been tampered ?

By setting the EnableViewStateMac to true in the @Page directive. This attribute checks the encoded and encrypted viewstate for tampering.
What are skins ?

A theme contains one or more skin files. A skin is simply a text file with a .skin extension. It contains definition of styles applied to server controls in an ASP.NET page.

For Example:

<asp:button runat="server" BackColor="blue" BorderColor="Gray" Font-Bold ="true" ForeColor="white"/>


Defines a skin that will be applied to all buttons throughout to give it a consistent look and feel.
What is the difference between Skins and Css files ?

The major difference between the two is that, Css is applied to HTML controls whereas skins are applied to server controls.
What is Instrumentation ?

Instrumentation is the ability to monitor an application so that information about the application’s progress, performance and status can be captured and reported.
What is RedirectPermanent in ASP.Net 4.0 ?

In earlier Versions of .Net, Response.Redirect was used, which issues an HTTP 302 Found or temporary redirect response to the browser (meaning that asked resource is temporarily moved to other location) which inturn results in an extra HTTP round trip. ASP.NET 4.0 however, adds a new RedirectPermanent that Performs a permanent redirection from the requested URL to the specified URL. and returns 301 Moved Permanently responses.

Example:

RedirectPermanent("/newpath/foroldcontent.aspx");

What is a bubbled event?

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

System.Web.Mail (SWM) is the .Net namespace which is used to send email in .Net Framework applications. SWM contains three classes:

1. MailMessage - used for creating and manipulating the mail message contents.
2. MailAttachments - used for creating a mail attachment to be added to the mail message.
3. SmtpMail - used for sending email to the relay mail server.
How to manage state in Asp.Net Web applications ?

State management can be done at client side and server side.

Client Side: In Client Side, it can be achieved with the help of View state, Cookies, Query String,hidden fields and control state.

Server Side: In Server side, it can be achieved with the help of Cache, Application, Session and Database.
Difference between Session and Cache ?

The main difference is session is per user, while cache will be for application scoped items.

1) Items put into a session will stay there, until the session ends, whereas Items in the cache can expire (will be removed from cache) after a specified amount of time. And also there is no guaranty that objects will not be removed before their expiration times as ASP.NET remove items from cache when the amount of available memory gets small. This process is called as Scavenging.

2) The session state can be kept external (state server, SQL server) and shared between several instances of your web app (for load balancing).
This is not the case with the cache.
Difference between Finalize() and Dispose()?

Finalize() method called by garbage collector at runtime when an object is no longer referenced.

Dispose() method is called by the code exiplicitily to dispose any object when needed by the program such as if there are unmanaged objects like file handles or any com object which can not be disposed by garbage collector, can be diposed using Dispose() method of IDisposable interface.

You do not know when finalize method will be execute by garbage collector.
What is managed code and unmanaged code ?

The code which is produced by (vb.net,c#,j#) .net framework language is called as managed code which is under the control of CLR.Garbage collector run automatically in managed code.
The code which is produced by third party language is called as unmanaged code, which does not run under the control of CLR.Garbage collector will not run in case of unmanaged code.
What is the importance of PostBackUrl property of a button?

By default every webform sumbits to itself,but if the PostBackUrl property of a button is set to the url of another page ,then the form is posted to that url instead of itself.

<asp:Button ID="btnCrossPagePostback" runat="server" PostBackUrl="~/Page2.aspx" Text="Cross Page Postback" />

Here the form is submitted to Page2 instead to the form containing the button.

Thanks
Shanti
What is Page Inspector in VS 2011 ?

It is new tool that brings browser diagnostics tools into Visual Studio and provides an integrated experience between the browser, ASP.NET, and source code.

Using Page Inspector, you can inspect elements in the integrated browser and see exactly which file and lines of code generated that element (HTML literal content and server-side code).

It also comes with a DOM Visualizer and CSS Tools in which you can modify the properties and see the changes in the browser in real time.
How do you turn off cookies for one page in your site?

It can be done in two ways.

1) If you want to turn off cookies at application level, set in web.config file.

cookie state= false


2) At page level use the Cookie.Discard property.
Where on the Internet would you look for Web services?

In UDDI. If you want to share your web service over the internet, you need to register it in UDDI server.

UDDI is the server which holds the list of web services.
Web service can only be written in .net?

No, it is not true that web services can only be written in .net. It can be written in any language, because web service is the concept of XML, so that it can be written in any platform.
What is meant by an Indexer ?

An indexer is a member which enables an object to be indexed in the same way as an array.

Example:

namespace ConsoleApplication

{
using System;
class Employee
{
private string[]name = new string[10];
public string this[int index]
{
get
{
return name[index];
}
set
{
name[index] = value;
}
}
}

class Test
{
public static void Main()
{
Employee emp = new Employee();
emp[0] = "Joydip";
emp[1] = "Manashi";
emp[2] = "Jini";
Console.WriteLine("The namesare:--");
for (int i = 0; i < 3;Console.WriteLine(emp[i++]))
;
Console.ReadLine();
}
}
}


The output is as follows:

The names are:--

Joydip

Manashi

Jini
Where the View State data is stored ?

View State data is stored in a hidden field called "__VIEWSTATE " on a web page.

Example :-

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTQ" />




Thanks and Regards
Akiii
How to refresh a page automatically after a certain amount of seconds in ASP.NET ?

<meta http-equiv="refresh" content="15">


The above code will refresh your page after every 15 seconds.


Note :- sites like www.espncricinfo.com apply this mechanism to refresh there page.


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