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

What is View Control? How it relates ActiveViewChanged?

The View Control is the part of the MultiView control and it does not support any special properties or methods. Its primary purpose is to act as a container for other controls. However, the view control does support the following two events:

Activate- It raises when the view becomes the selected view in the MultiView control.
Deactivate- It raises when another view becomes the selected view in the MultiView control.

The multiview control which supports this event. This event is raised when a new view control is selected.
What a Wizard control can contain?

A Wizard control contains one or more WizardStep controls that represent steps in the wizard. The WizardStep control supports the following properties:

AllowReturn- It enables you to prevent or allow a user to return to this step from a future step.

Name- It enables you to return the name of the WizardStep control.

StepType- It enables you to get or set the type of wizard step. In this the possible values are Auto, Complete, Finish, Start, and Step.

Title- It enables you to get or set the title of the WizardStep. The title is displayed in the wizard sidebar.

Wizard- It enables you to retrieve the Wizard control containing the WizardStep.

The WizardStep also supports the following two events:

Activate- Raised when a WizardStep becomes active.

Deactivate- Raised when another WizardStep becomes active.
What is using statement versus using directive?

You can create an instance in a using statement to ensure that Dispose is called on the object when the using statement is closed or else we can say Using automatically calls the stream object’s Dispose method when the Using statement is closed. A using statement can be exited either when the end of the using statement is reached or if an exception is thrown and control leaves the statement block before the end of the statement.

The using directive has two uses:
• Create an alias for a namespace (a using alias).
• Permit the use of types in a namespace, such that, you do not have to qualify the use of a type in that namespace (a using directive).
Describe the Managed Execution Process?

It includes the following steps that are as follows:

• First you choose a compiler. To get the benefits provided by the common language runtime, you must use one or more language compilers that target the runtime.

• You can compile your code to Microsoft intermediate language (MSIL) and when compiling, it translates your source code into MSIL and generates the required metadata.

• When you are compiling the code from MSIL to native code, then at that execution time, a just-in-time (JIT) compiler translates the MSIL into native code. During this compilation, code passes a verification process which examines the MSIL and metadata to find out whether the code can be determined to be type safe or not.

• Executing your code. The common language runtime provides the platform that enables execution to take place as well as a different type of services that can be used during execution.
What is Active Directory? Explain the steps to configure ActiveDirectoryMembershipProvider(ADMP)?

It is a programmatic interface for Microsoft Windows directory. It enables your applications to interact with diverse directories on a network, using a single interface. Visual Studio .NET and the .NET Framework that makes it easy to add ADSI functionality with the DirectoryEntry and DirectorySearcher components. Using this, you can create applications that perform common administrative tasks, such as backing up databases, accessing printers, and administering user accounts etc.

The ActiveDirectoryMembershipProvider is a membership provider that is included in ASP.NET Framework. You can use this provider to store the user information in Active Directory or ADAM (Active Directory Application Mode). This is a light weight version of Active Directory. If you want to use ASP.NET membership with ADAM, then you need to follow these steps:

• Create an ADAM instance and create the required classes.
• Configure your application to use the ActiveDirectoryMembershipProvider and connect to the ADAM instance.

For more details, read http://msdn.microsoft.com/en-us/library/hsxk2787(VS.71).aspx
What is Access Control Lists? How to add a rule to the Access Control List?

These are the way resources such as directories and files are secured in the NTFS file system which is commonly used file system in all windows. You can also view this file by selecting the security tab from the file’s properties dialog. To get this security tab follow the steps that is mentioned below...
Step-1: Create a text file.
Step-2: Right click on that file and click on properties.
Now you will get that security tab.

Code snippet to add a rule to the Access Control Li st:

System.Security.AccessControl.FileSecurity sec = 

System.IO.File.GetAccessControl (Server.MapPath(“Test.txt”));

sec.AddAccessRule (new System.Security.AccessControl.FileSystemAccessRule (
@”WIN7\TestUser”,
System.Security.AccessControl.FileSystemRights.FullControl,
System.Security.AccessControl.AccessControlType.Allow
)
);

System.IO.File.SetAccessControl (Server.MapPath (“Test.txt”), sec);

What is the difference between ReadOnly and Const?

ReadOnly: A ReadOnly field can be initialized either at the declaration time or in the constructor. The ReadOnly fields can have different values depending on the constructor used. The ReadOnly fields can be used for run time constants. It marks the field as unchangeable but the property can be changed inside the constructor of the class.

Const: A Const field can only be initialized at the declaration of the field. The Const fields can be used for compile time constants and it can’t change at run time. In a program where ever we are using Const, then that value will be replaced by the compiler.

Code Snippet:
namespace ClassLibrary

{
public class Test
{
public const int ConstValue = 10;
public static readonly int ReadonlyValue = 20;
}
}


By looking to the above code snippet, we can say ConstValue is declared as literal and it has an int value assigned to it whereas ReadonlyValue is declared as initonly and it has not been assigned any value to it.
So we can say that if a type is declared as Const, its value is known as compile time, but when the value that is declared as static readonly field, that cannot be known at compile time.
What is the meaning of neutral cultures in ASP.NET?

A neutral culture is a culture which represents general languages like English or Spanish and a specific language and region. The ASP.NET application which assigns that culture to all the threads running for that Web application and those Threads are the basic units where the server allocates the process time. When user set culture attribute for a Web application in Web.config, then it will maintain multiple threads for a Web application within the aspnet_wp.exe worker process.
What's the advantage of using Windows authentication in a Web application?

The advantage of using Windows authentication in a Web Application is:

• Web application can use the same security that applies to your windows application which will authenticate to your window like user names, passwords, and permissions.

• To access the Web application, users logged on to the network. It is important that user doesn’t logged on again because when window is opened then it will automatically authenticate the user to use web application.
How will you get a User Identity in an application?

With the help of User object’s Identity property you can be able to get User Identity. The Identity property which returns an object that includes the user name and the role information.

Sample Code Snippet:
public partial class _Default : System.Web.UI.Page

{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = User.Identity.IsAuthenticated.ToString();
Label2.Text = User.Identity.Name;
Label3.Text = User.Identity.AuthenticationType;
}
}

What is the default expiration period for Session and Cookies, and maximum size of ViewState?

The default Expiration Period for a Session is 20 minutes.

The default Expiration Period for a Cookie is 30 minutes.

The maximum size of the viewstate is 25% of the page size.
Describe about Server Side State Management?

The Sever side state management technique provides better security and reduces bandwidth. Basically this option is for storing page information that tends to have security than client side options, but they can use more web server resources which may lead to scalability issues when the size of the information is large.

ASP.Net provides several options to implement Server Side State Management are explained below.

Application State: This State information is available to all pages, regardless of which user requests a page. The Application State variables are the global variables for an ASP.NET application. The ASP.NET provides application state via the HttpApplicationState class. You can also store your application specific values in application state, which is managed by the server.

Session State: The Session State information is available to all pages opened by a user during a single visit. This method stores the session specific information (that is values and objects in session state) which is managed by the server and that is visible only within the session. This session state is available as the HttpSessionState class. The Session State which identifies the requests from the same browser during a limited time and it provides the ability to persist variable values for the duration of that session.

Profile properties: It allows you to store user specific data. Unlike session state, the profile data is not lost when a user's session expires. This allows you to manage the user information without requiring, creating and maintaining your own database. It can be used in both multi-computer and multi-process configurations. This property provides a generic storage system that allows you to define and maintain any kind of data while making the data available in a type-safe manner.

Database support: It is also used for database support to maintain the state on your web site. This is used basically with the help of cookies or session state. The Database Support to maintain state information by using a relational database for different reasons like security, personalization, consistency, and data mining.
What are the advantages and disadvantages of using Session State?

The advantages of using session state are:

• It is easy to implement and is just similar to using View State.
• Accessing of data is very fast as it stores session data in memory object of the current application domain.
• It ensures platform scalability and it works in the multi-process configuration.
• Also it ensures data durability, since the session state retains data even if ASP.NET work process restarts (in outproc session).

The disadvantages of using session state are:

• As the session state data is stored in server memory, it is not advisable to use session state when you are working with large sum of data.
• With the use of Session state, it will affect the performance of memory, because session state variable stays in memory until you destroy the state.
• If the worker Process or application domain recycles all session data will be lost.
• We can't use it in web Garden scenarios and is not suitable for web farm scenarios also.
Explain what are the different Session State Modes that supports ASP.NET?

ASP.NET supports three Session State modes. Those are

InProc: This mode is faster among all the storage modes and it stores the session data in the ASP.NET worker process. It also effects on performance of data if the amount of data to be stored is large.

StateServer: This mode is basically for serialization and de-serialization of objects. State Server mode is slower than InProc mode as it stores data in an external process. State Server mode is maintained on different systems and the session state is serialized and stored in memory in a separate process.

SQLServer: Basically this mode can be used in the web form which secures the session state and it is reliable for the storage of a session state. In this storage mode, the Session data is serialized and stored in a database table in the SQL Server database.
In which way you identify a Master Page and how you can bind a Content Page to a Master Page? Can a master page be nested?

The master page is identified by @Master directive and that replaces the @Page directive which is used for ordinary .aspx or content page pages.

The MasterPageFile attribute of a content page's @Page directive is used to bind a Content Page to a Master Page.

Yes, the master pages can be nested.
How can you dynamically assign a Master Page?

You can assign a master page dynamically in the PreInit event of the content page by using the Page class MasterPageFile property. Below is the code snippet to assign a master page dynamically.

void Page_PreInit(Object sender, EventArgs e)

{
this.MasterPageFile = "MasterPage.master";
}

Explain what are the different ways to globalize the web applications?

There are three different ways to globalize the web applications:

Detect and redirect approach: In this approach the applications have lots of text file content which requires translation and few are some executable components. In this we can create a separate Web application for each supported culture present in that application and then identify the user’s culture and then redirect the request to the appropriate application.

Run-time adjustment approach: This approach is best for that kind of applications where limited amounts of content are present. For this kind of approach we can create a single Web application that detects the user’s culture and that adjusts output at run time using format specifiers and other tools.

Satellite assemblies approach: With this approach we create a single Web application which stores culture-dependent strings in resource files and that are compiled into satellite assemblies. It identifies the user’s culture and load strings from the appropriate assembly at run time. This approach is best for applications which generates content at run time or that have large executable components.
What are the different types of Caching in ASP.Net ?

Types of Caching

Caching in ASP.NET can be of the following types

• Page Output Caching
• Page Fragment Caching
• Data Caching
What are the properties and methods of cache Class ?

Cahe Class ::


The Add/Insert method of the Cache class is used to add/insert an item into the cache. The Remove method removes a specified item from the cache. The Cache class contains the following properties and methods.

Properties

• Count
• Item


Methods

• Add
• Equals
• Get
• GetEnumerator
• GetHashCode
• GetType
• Insert
• Remove (Overloaded)
• ToString

What is Application Pooling and what is its advantage ?

Application Pooling ::


An Application Pool can contain one or more applications and allows us to configure a level of isolation between different Web applications.

For example,
Advantage :

if you want to isolate all the Web applications running in the same computer, you can do this by creating a separate application pool for every Web application and placing them in their corresponding application pool.
Because each application pool runs in its own worker process, errors in one application pool will not affect the applications running in other application pools. Deploying applications in application pools is a primary advantage of running IIS 6.0 in worker process isolation mode because you can customize the application pools to achieve the degree of application isolation that you need.

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