ASP and ASP.NET questions

  1. Explain the life cycle of an ASP .NET page.

Life cycle of ASP.Net Web Form

Page Request >> Start >> Page Init >> Page Load >> Validation >> PostBack Event Handling >> Page Rendering >> Page Unload

Page Request - When the page is requested ASP.Net determines whether the page is to be parsed and compiled or a cached verion of the page is to be sent without running the page.

Start - Page propertied REQUEST and RESPONSE are SET, if the page is pastback request then the IsPostBack property is SET and in addition to this UICulture property is also SET.

Page Initilization - In this the UniqueID of each property is SET. If the request was postback the data is not yet loaded from the viewstate.

Page Load - If it was a postback request then the data gets loaded in the control from the ViewState and control property are set.

Validation - If any control validation present, they are performed and IsValid property is SET for each control.

PostBack Event Handling - If it was a postback request then any event handlers are called.

Page Rendering - Before this the viewstate is saved from the page and RENDER method of each page is called.

Page Unload - Page is fully rendered and sent to the client(Browser) and is discarded. Page property RESPONSE and REQUEST are unloaded.

  1. Explain the .NET architecture.

Net architecture
The order starting from the bottom

1. Physical Hardware Machine (Intel Pentium, apple machntosh)
2. Operating System (Microsoft Windows, Linux etc)
3. Common Language Runtime (CLR)
4. Framework Class Library (FCL)
5. ADO.Net and XML Library
6. WinForm, Web Application, Web Serivces (Managed Application)

  1. What are object-oriented concepts?

Class: The formal definition of an object. The class acts as the template from which an instance of an object is created at run time. The class defines the properties of the object and the methods used to control the object’s behaviour.

Object: An object is an instance of a class.

Encapsulation: hides detailed internal specification of an object, and publishes only its external interfaces. Thus, users of an object only need to adhere to these interfaces. By encapsulation, the internal data and methods of an object can be changed without changing the way of how to use the object.

Inheritance: A class that derives from another class - known as the base class - inherits the same methods and properties. This promotes reuse and maintainability.

Abstraction: the describing of objects by defining their unique and relevant characteristics (properties). Whilst an object may have 100s of properties normally only those properties of importance to the situation are described. (eg life policies premiums are normally important; whereas the time of day a policy was purchased is not usually of value).

Polymorphism: Allows objects to be represented in multiple forms. Even though classes are derived or inherited from the same parent class, each derived class will have its own behavior. (Overriding and hiding methods)

  1. How do you create multiple inheritance in c# and .NET?

public class MyTest: IPaidInterface, ISoldInterface

  1. When is web.config called?

Web.config is an xml configuration file. It is never directly called unless we need to retrieve a configurations setting.

  1. How many weg.configs can an application have?

There can only be 1 web.config in an application.

@Param, Each directory can have a web.config file. but, the settings like httpmodules, authentication can resides in root directory’s web.config file.

  1. How do you set language in weg.config?

defaultLanguage=”vb”: This specifies the default code language.
debug=”true”: This specifies that the application should be run in debug mode

  1. What does connection string consist of?

The connection string consists of the following parts:

In general:
Server: Whether local or remote.

Uid: User Id (sa-in sql server)

Password: The required password to be filled-in here

Database: The database name.

And some fields to indicate whether the connection is trusted or not.

  1. Where do you store connection string?

The connection string can be stored in the WEB.Config file under element appsettings

  1. What is abstract class?

Abstract class connot be instantiated instead it has to be inherited. The methods in abstract class can be overridetn in the child class.

  1. What is difference between interface inhertance and class inheritance?

Interface inheritance -
1. The accessibility modifier in Interface is public by defalut.
2. All the methods defined in the interface class should be oveririden in the child class.

Class Inheritance -
1. There is not restriction on the acessibility modifier in a class.
2. Only the method that are defined virtual should be overriden.

  1. What are the collection classes?

Queue, Stack, BitArray, HashTable, LinkedList, ArrayList, NameValueCollection, Array, SortedList , HybridDictionary, ListDictionary, StringCollection, StringDictionary

  1. What are the types of threading models?

Single Threading: This is the simplest and most common threading model where a single thread corresponds to your entire application’s process.

Apartment Threading (STA): This allows multiple threads to exist in a single application. In single threading apartment (STA), each thread is isolated in it’s own apartment. The process may contain multiple threads (apartments) however when an object is created in a thread (i.e. apartment) it stays within that
apartment. If any communication needs to occur between different threads (i.e. different apartments) then we must marshal the first thread object to the second thread.

Free Threading: The most complex threading model. Unlike STA, threads are not confined to their own apartments. Multiple treads can make calls to the same methods and same components at the same time.

  1. What inheritance does VB.NET support?

Single inheritance using classes or multiple inheritance using interfaces.

  1. What is a runtime host?

The runtime host is the environment in which the CLR is started and managed.

  1. Describe the techniques for optimizing your application?

. Avoid round-trips to server. Perform validation on client.
. Save viewstate only when necessary.
. Employ caching.
. Leave buffering on unless there is a dire need to disable it.
. Use connection pooling.
. Use stored procedures instead of in-line SQL or dynamic SQL.

  1. Differences between application and session

The application level variable hold value at the application level and their instances are destroyed when the no more client access that application, whereas session corresspond to a individual user accessing the application.

  1. What is web application virtual directory?

Virtual directory is the physical location of the application on the machine.

By defalut it’s - inetpub/wwwroot

  1. If cookies is disabled in client browser, will session tracking work?

No, maintaning value in cokkie woont be possible. In that case you have to make use of other ways to maintain state of the data on page.

you can check whether client support cookies or not by using

Request.Browser.Cookies property.

  1. Will the following code execute successfully: response.write(’value of i=’+i);

Yes.

  1. What is a Process, Sesion and Cookie?

Process - Instance of the application

Session - Instance of the user accessing the application

Cookie - Used for storing small amount of data on client machine.

  1. How is Polymorphism supports in .NET?

Polymorphism supports to objects to be represent in different forms..

  1. What are the 2 types of polymorphism supports in .NET?

Overriding and overloading

  1. ASP.NET OBJECTS?

Application,Request,Responce,server and session

  1. What is side by side execution?

Asynchronous execution in which application keeps on running instead of waiting for the result of previous stage execution.

  1. Explain serialization?

Serialization is a process of converting an object into a stream of bytes.

.Net has 2 serializers namely XMLSerializer and SOAP/BINARY Serializer.

Serialization is maily used in the concept of .Net Remoting.

  1. Explain a class access specifiers and method acess specifiers.

1) Public : available throughout application.
2) Private : available for class and its inherited class.
3) Protected : restricted to that class only.
4) Internal : available throughout that assembly.

  1. What is the difference between overloading and overriding ? how can this be .NET

Very simple way to remember the diff between them.

Overriding - Method has the same signature as the parent class method.

Overloading - Method having diff parameters list or type or the return type may be different.

  1. Explain virtual function and its usage.

Virtual function is that which is get override by the derived class to implement polymorphism.

  1. How do you implement inhetance in .NET?

In C# we implement using the following signature

:

In VB.Net we implemets using the following signature

Inherits

  1. If I want to override a method 1 of class A and this class B then how do you declared

answer :public virtual void method1(){ }………..In class A. public override void method1(){}…………..In class B.

  1. Explain friend and protected friend.

Friend/Internal - Method, Properties in that class can be accessed by all the classes within that particular assembly.

Protected Friend/Protected Internal - Methods, Properties can be accessed by the child classes of that particular class in that particular assembly.

  1. Explain multiple and multi_level inheritance in .NET?

Multiple Inheritance: ex. Public void Employee : Persons, Iemployee. Means a class can be inherited by more than one interface OR inherited by one class and
more than one interfaces.
Multi level inheritance: ex. Public void Person () {}, Public void Customer : person {} , Public void employee : customer{}.

  1. What is isPostback property?

This property is used to check whether the page is being loaded and accessed for the first time or whether the page is loaded in response to the client postback.

Example:
Consider two combo boxes
In one lets have a list of countries
In the other, the states.

Upon selection of the first, the subsequent one should be populated in accordance. So this requires postback property in combo boxes to be true.

  1. What is dictionary base class?

Answer: Provides the abstract base class for a strongly typed collection of key/value pairs.
Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll)

  1. What are indexes .NET?

Answer: Indexes are set up as a subset of data from the column it is created in an index table and a set of pointers to the physical table itself. The index tables are updated when data is inserted, updated or deleted. This can actually have negative performance impact if indexes are unnecessarily created. The overuse of indexes can become as much as burden to the application as not having indexes.

  1. How can indexes be implemented in .NET?

What is maximum length of VARCHAR in SQL-SERVER?
ANS.:

VARCHAR[(n)]
Null-terminated Unicode character string of length n,
with a maximum of 255 characters. If n is not supplied, then 1 is assumed.

29. How to find the SQL server version from Query Analyser
To determine which version of Microsoft SQL Server 2005 is running, connect to SQL Server 2005 by using SQL Server Management Studio, and then run the following Transact-SQL statement:

SELECT SERVERPROPERTY(’productversion’), SERVERPROPERTY (’productlevel’), SERVERPROPERTY (’edition’)

The results are:
• The product version (for example, “9.00.1399.06″).
• The product level (for example, “RTM”).
• The edition (for example, “Enterprise Edition”).
For example, the result looks similar to:
9.00.1399.06 RTM Enterprise Edition

How to determine which version of SQL Server 2000 is running
To determine which version of SQL Server 2000 is running, connect to SQL Server 2000 by using Query Analyzer, and then run the following code:

SELECT SERVERPROPERTY(’productversion’), SERVERPROPERTY (’productlevel’), SERVERPROPERTY (’edition’)

The results are:
• The product version (for example, 8.00.534).
• The product level (for example, “RTM” or “SP2″).
• The edition (for example, “Standard Edition”). For example, the result looks similar to:

2. How many classes can a single.NET DLL contain?
Ans. One or more

3. What are good ADO.NET object(s) to replace the ADO Recordset object?
Ans. The differences includes

In ADO, the in-memory representation of data is the recordset.
In ADO.net, it is the dataset

A recordset looks like a single table in ADO
In contrast, a dataset is a collection of one or more tables in ADO.net

ADO is designed primarily for connected access
ADO.net the disconnected access to the database is used

In ADO you communicate with the database by making calls to an OLE DB provider.
In ADO.NET you communicate with the database through a data adapter (an
OleDbDataAdapter, SqlDataAdapter, OdbcDataAdapter, or OracleDataAdapter object), which makes calls to an OLE DB provider or the APIs provided by the underlying data source.

In ADO you cant update the database from the recordset.
ADO.NET the data adapter allows you to control how the changes to the dataset are transmitted to the database.

60)What is Active Directory? What is the namespace used to access the Microsoft Active Directories?
Ans:
Active Directory is simply a hierarchical, object-orientated database that represents all of your network resources. At the top there’s typically the Organization (O), beneath that Organizational Units (OU) as containers, and finally objects that consist of your actual resources.

AD provides the ability to control who has access to what resource and when. This includes devices such as printers, files, and any other local network resource or item on the distributed network.

Within the .NET Framework we are provided with the System.DirectoryServices namespace, which in turns uses Active Directory Services Interfaces (ADSI).

66)How will you register COM+ services?

Ans: You register the component dynamically when the first instance is created.
Or, you can manually register the component with Regsvcs.exe.

To use Regsvcs.exe, follow these steps:

Click Start, point to Programs, point to Microsoft Visual Studio .NET, and
then click Visual Studio .NET Tools to open a .NET command prompt.
At a .NET command prompt, type regsvcs servicedcom.dll.

Interview questions for .NET

  1. What is a static class?

A static class is a class which can not be instantiated using the ‘new’ keyword. They also only contain static members, are sealed and have a private constructor.

  1. What is static member?

A static member is a method, field, property or event that can be called without creating an instance of its defining class. Static members are particularly useful for representing calculations and data that are independent of object state.

  1. What is static function?

A static function is another term for a static method. It allows you to execute the function without creating an instance of its defining class. They are similar to global functions. An example of a static function could be: ConvertFromFarenheitToCelsius with a signature as follows:

public static double ConvertFromFarenheitToCelsius (string valToConvert)
{
//add code here
}

  1. What is static constructor?

A static constructor has a similar function as a normal constructor i.e. it is automatically called the first time a class is loaded. The differences between a conventional constructor are that it cannot be overloaded, cannot have any parameters nor have any access modifiers and must be preceded by the
keyword static. In addition, a class with a static constructor may only have static members.

  1. How can we inherit a static member?

When inheriting static members there is no need to instantiate the defining class using the ‘new’ keyword.

public class MyBaseClass
{
MyBaseClass()
{
}
public static void PrintName()
{
}

}

public class MyDerivedClass : MyBaseClass
{
MyDerivedClass ()
{
}

public void DoSomething()
{
MyBaseClass.GetName();
}

}

  1. Can we use a static function with a non-static variable?

No.

  1. How can we access static variable?

By employing the use of a static member field as follows:
public class CashSales
{
//declare static member field
private static int maxUnitsAllowed = 50;

//declare method to return maximum number of units allowed

public static int GetMaxUnitsAllowed ()
{
Return maxUnitsAllowed;
}

}
The static field can now be accessed by simply doing CashSales.GetMaxUnitsAllowed(). No need to create an instance of the class.

  1. Why main function is static?

Because it is automatically loaded by the CLR and initialised by the runtime when the class is first loaded. If it wasn’t static an instance of the class would first need to be created and initialised.

  1. How will you load dynamic assembly? How will create assesblies at run time?

Load assembly:
By using classes from the System.Reflection namespace.
Assembly x = Assembly.LoadFrom( “LoadMe.dll” );

Create assembly;
Use classes from System.CodeDom.Compiler;

  1. What is Reflection?

The System.Reflection namespace provides us with a series of classes that allow us to interrogate the codebase at run-time and perform functions such as dynamically load assemblies, return property info e.t.c.

  1. If I have more than one version of one assemblies, then how will I use old version (how/where to specify version number?) in my application?

The version number is stored in the following format: …. The assembly manifest can then contain a reference to which version number we want to use.

  1. How do you create threading in.NET? What is the namespace for that?

System.Threading;

//create new thread using the thread class’s constructor

Thread myThread = new Thread(new ThreadStart (someFunction));

  1. What do you mean by Serialize and MarshalByRef?

Serialization is the act of saving the state of an object so that it can be recreated (i.e deserialized) at a later date.
The MarshalByRef class is part of the System.Runtime.Remoting namespace and enables us to access and use objects that reside in different application domains. It is the base class for objects that need to communicate across application domains. MarshalByRef objects are accessed directly within their own application domain by using a proxy to communicate. With MarshalByValue the a copy of the entire object is passed across the application domain

  1. What is the difference between Array and LinkedList?

An array is a collection of the same type. The size of the array is fixed in its declaration.
A linked list is similar to an array but it doesn’t have a limited size.

  1. What is Asynchronous call and how it can be implemented using delegates?

A synchronous call will wait for a method to complete before program flow is resumed. With an asynchronous call the program flow continues whilst the method executes.

//create object
SomeFunction objFunc = new SomeFunction();

//create delegate
SomeDelegate objDel = new SomeDelegate(objFunc.FunctionA);

//invoke the method asynchronously (use interface IAsyncResult)
IAsyncResult asynchCall = SomeDelegate.Invoke();

  1. How to create events for a control? What is custom events? How to create it?

An event is a mechanism used in a class that can be used to provide a notification when something interesting happens. (typical evens in a windows application include: change text in textbox, double click or click a button, select an item in dropdown box).

A custom event is an event created by the user that other developers can use. For example assuming that we have a CashTransaction class and we have a bank balance property in that class. We may want to set-up an event that provides a notification when the bank balance drops below a certain amount. In order to produce an event the process would be roughly as follows:

Create the class for the event derived from EventArgs.
Create a delegate with a return type of void.
Create a class containing the method that will activate the event.
Create a class with methods to handle the event.

  1. If you want to write your own dot net language, what steps you will you take care?

We will need to ensure that the high level code is compiled to MSIL (Microsoft intermediate language) so that it can be interpreted by the CLR.

  1. Describe the diffeerence between inline and code behind - which is best in a loosely coupled solution?

The term ‘code behind’ refers to application code that is not embedded within the ASPX page and is separated out into a separate file which is then referenced from the ASPX page. Inline code is the traditional ASP architectural model where business logic code was embedded within the ASP page. Separating the business logic code from the presentation layer offers several advantages:

1) It allows graphic designers and web developers to work on the presentation layer whilst the application developers concentrate on the business logic.
2) The codebehind file is compiled as a single dll increasing the efficiency of the application,
3) The codebehind model offers a true OO development platform,
4) It speeds up development time as it allows developers to fully maximise the features of the .NET framework such as Cahing, ViewState, Session, Smart Navigation etc.
5) Code is much easier to maintain and susceptible for change.
6) The compiler and VS.NET provides much better support for error checking, intellisense and debugging when using the code behind model.

  1. How dot net compiled code will become platform independent?

The raison d’etre for .NET was to cater for multiples languages on a single windows platform whereas the aim of Java was to be a single language on multiple platforms. The only way that .NET can be platform independent is if there is a version of the .NET framework installed on the target machine.

  1. Without modifying source code if we compile again, will it be generated MSIL again?

No.

  1. How does you handle this COM components developed in other programming languages in.NET?

use TlbImp.exe to import the COM types into your .NET project. If no type library for the COM component then use System.Runtime.InteropServices
use RegAsm.exe to call a .NET developed component in a COM application.

  1. How CCW (Com Callable Wrapper) and RCW (Runtime Callable Wrappers) works?

CCW: When a COM application calls a NET object the CLR creates the CCW as a proxy since the COM application is unable to directly access the .NET object.
RCW: When a .NET application calls a COM object the CLR creates the RCW as a proxy since the .NET application is unable to directly access the .COM object.

  1. What are the new thee features of COM+ services, which are not there in COM (MTS)?

Role based security.
Neutral apartment threading.
New environment called context which defines the execution environment

  1. What are the differences between COM architecture and.NET architecture?

.Net architecture has superseded the old COM architecture providing a flexible rapid application development environment which can be used to create windows, web and console applications and web services. .NET provides a powerful development environment that can be used to create objects in any .NET compliant language. .NET addresses the previous problems of dll hell with COM by providing strongly named assemblies and side-by-side execution where two assemblies with the same name can run on the same box.

  1. Can we copy a COM dll to GAC folder?

No. It only stores .NET assemblies.

  1. Can you explain what inheritance is and an example of when you might use it?

Inheritance is a fundamental feature of any OO language. It allows us to inherit the members and attributes from a base class to a new derived class. This leads to increased code reusability and also makes applications easier to develop, maintain and extend as the new derived class can contain new features not available in the base class whilst at the same time preserving the attributes inherited from the base class.

  1. How can you write a class to restrict that only one object of this class can be created (Singleton class)?

Use the singleton design pattern.
public sealed class Singleton
{
static readonly Singleton Instance=new Singleton();

static Singleton()
{
}

Singleton()
{
}

public static Singleton Instance
{
get
{
return Instance;
}
}
}

  1. What are virtual destructures?

A constructor can not be virtual but a destructor may. Use virtual destructors when you want to implement polymorphic tearing down of an object.

  1. What is close method? How its different from Finalize and Dispose?

finalise is the process that allows the garbage collector to clean up any unmanaged resources before it is destroyed.
The finalise method can not be called directly; it is automatically called by the CLR. In order to allow more control over the release of unmanaged resources the .NET framework provides a dispose method which unlike finalise can be called directly by code.
Close method is same as dispose. It was added as a convenience.

  1. What is Boxing and UnBoxing?

Boxing is the process of converting a value type to a reference type. More specifically it involves encapsulating a copy of the object and moving it from stack to heap. Unboxing is the reverse process.

  1. What is check/uncheck?

checked: used to enable overflow checking for arithmetic and conversion functions.
unchecked: used to disable overflow checking for arithmetic and conversion functions.

what is different between BCL and FCL in dot net?
The Base Class Library (BCL), sometimes incorrectly referred to as the Framework Class Library (FCL) (which is a superset including the Microsoft.* namespaces), is a library of types available to all languages using the .NET Framework. The BCL provides classes which encapsulate a number of common functions such as file reading and writing, graphic rendering, database interaction, XML document manipulation, and so forth. The BCL is much larger than other libraries, but has much more functionality in one package.

What is difference between web.config and machine.config?
Web config file gives the configuration setting s of a particular application and machine .config contains the configuration setting of a particular machine.the web.config settings of a particular application overwrites the machine.config

What is delegate?
Delegate encapsulates a reference to a method.
It has two types,
1.Simple delegate
At a time Only one method can be invoked by single call.
e.g: del delname=new delname(obj.function_name)//To assign a method
delname()//To call that method

2.multicast delegate
At a time two or more methods can be invoked by single call.

What is virtual polymorphism?
Polymorphism means ability to take more than one form.
It likes same name but different meanings.
virtual polymorphism means method name is same for base class and derived class. It is used for instead of “override” keyword.

.NET WebDev and Web services questions

  1. How does ASP page work?

An ASP page is an HTML page that contains server-side scripts written on VBScript or Jscript or Perl that are processed by the Web server before being sent to the user’s browser. ASP can be combined with HTML, XML and COM to create Web sites.
Server-side scripts run when a browser requests an .asp file from the Web server. ASP is called by the Web server, which processes the requested file and executes script commands. It then formats a standard Web page and sends it to the browser.

  1. How ASP.NET page works?

Web Forms pages are built with ASP.NET technology. ASP.NET is built on the .NET Framework, so the entire framework is available to any ASP.NET application. Your applications can be written in any language compatible with the common language runtime, including Microsoft Visual Basic, Visual C#, and JScript .NET.

The ASP.NET page framework is a programming framework that runs on a Web server to dynamically produce and manage Web Forms pages.

Web Forms pages run on any browser or client device.

  1. What are the contents of cookie?

Cookie is a small amount of data and it contains page-specific information(usually user ID) the server sends to the client along with page output. Cookies can contain only strings.

  1. How do you create a permanent cookie?

Dim oCookie As New HttpCookie(“permanentCookie”,”Bonjour!”)
oCookie.Expires=#12/01/2006#
Response.Cookies.Add(oCookie)

  1. What is ViewState? What does the “EnableViewState” property do? Whay would I want it on or off?

View state is a property of Web Forms page and each control of the page to save their values so it can be used between round trips to the server.
When the page is processed, the current state of the page and controls is inserted into a string and saved in the page as a hidden field. When the page is posted back to the server, the page parses the view state string at page initialization and restores property information in the page.

EnableViewState indicates whether the page maintains its view state, and the view state of any server controls it contains, when the current page request ends.

The benefits of using ViewState are it automatically store values between multiple requests for the same page, it is saved as a hidden field of the page and no server resources required.

It is better to disable ViewState if a control or a page contain large amount of data. Saving such an amount can affect the form load. Because the view state is stored in the page itself, storing large values can cause the page to slow down when users display it and when they post it.

  1. Give an example of what might be best suited to place in the Application_Start and Session_Start subroutines?

In Application_Start you can initialize the variables, upload data from database table and store in ViewState or in Cache.

In Session_Start you can count the number of active sessions, automatically redirect users to the certain Web page at the beginning of the session.

  1. Describe the role of global.asax?

The Global.asax file is an optional file that contains code for responding to application-level events raised by ASP.NET or by HttpModules and initializing global application objects. The Global.asax file resides in the root directory of an ASP.NET-based application.

  1. How can you debug your.NET application?

You can debug .NET application using Visual Studio .NET.
If Visual Studio .NET is not installed you can use Systems.Diagnostics classes, Runtime Debugger (Cordbg.exe), or Microsoft Common Language Runtime Debugger (DbgCLR.exe)

System.Diagnostics includes the Trace and Debug classes for tracing execution flow, and the Process, EventLog, and PerformanceCounter classes for profiling code.
The Cordbg.exe command-line debugger can be used to debug managed code from the command-line interpreter.

DbgCLR.exe is a debugger with the Windows interface for debugging managed code.

  1. How do you deploy your ASP.NET application?

To create ASP.NET Web applications, you use a standard deployment model: your project is compiled and the resulting files are deployed. The Web Forms code-behind class file (.aspx.vb, or .aspx.cs) is compiled into a project .dll file along with all other class files included in your project. This single project .dll file is then deployed to the server, without any source code. When a request for the page is received, the project .dll file is instantiated and executed.

  1. Where do we store our connection string in ASP.NET application?

You can store Connection String in Web.config file:

create a new add key in the appSettings element.

Or in the Registry

add new subkeys to the SOFTWARE key in the HKEY_LOCAL_MACHINE

  1. Explain security types in ASP.NET?

ASP.NET, in conjunction with Microsoft Internet Information Services (IIS), can authenticate user credentials such as names and passwords using any of the following authentication methods:
• Windows: Basic, digest, or Integrated Windows Authentication. If the user making the request has already been authenticated in a Windows-based network, IIS can pass the user’s credentials through when requesting access to a resource.

• Microsoft Passport authentication
Passport authentication allows implementing single sign-in for multiple applications or websites that want to authenticate users. The user is expected to use only one username and password to access all the sites.

• Forms authentication
generally refers to a system in which unauthenticated requests are redirected to a registration form. The user provides credentials and submits the form. If the application authenticates the request, the system issues a cookie that contains the credentials or a key for reacquiring the identity.

• Client Certificate authentication
IIS supports the use of digital certificates and the secure sockets layer (SSL). In this scenario, either the server or the client has a certificate — a digital identification — that they have obtained from a third-party source. The certification is passed to your application with requests. It can be mapped to a Windows user account and granted appropriate permissions.

  1. Explain different Authentication modes in ASP.NET?

Authentication modes are: Windows, Forms, Passport, or None.

ASP.NET uses Windows authentication in conjunction with IIS authentication. It authenticates the identity using basic, digest, or Integrated Windows authentication, or some combination of them.
All users are authenticated as soon as they log on to Windows.

Passport authentication is centralized authentication service provided by Microsoft that offers a single log on and core profile services for member sites.

Form authentication generally refers to a system in which unauthenticated requests are redirected to a registration form. The user provides credentials and submits the form. If the application authenticates the request, the system issues a cookie that contains the credentials or a key for reacquiring the identity.

None authentication is used when you want to apply anonymous authentication or a custom authentication scheme.

  1. How.NET has implemented security for web applications?

To secure Web application, .NET uses two functions: Authentication and Authorization.
Authentication is the process of obtaining identification credentials such as name and password from a user and validating those credentials against some authority.
Authorization limits access rights by granting or denying specific permissions to an authenticated identity.

  1. How to do forms authentication in ASP.NET?

You need to create an entry in Web.Config
authentication mode=”Forms”
forms
name=”.TheCookie”
loginUrl=”/login/login.aspx”
protection=”All”
timeout=”70″
path=”/”/
/authentication

  1. Explain authentication levels in.NET?

Authentication can be declared only at the machine, site, or application level.

  1. Explain authorization levels in.NET?

Authorization controls client access to URL resources. It can be declared at any level: machine, site, application, subdirectory, or page.

  1. How can you debug an ASP page, without touching the code?

You can debug ASP page using either the Microsoft Script Debugger or Visual InterDev

  1. How can you handle Exceptions in ASP.NET?

You can handle Exceptions using Try Catch Finally block.

Also in Global.asax you can create an application-wide error handler Application_Error or create a handler in a page for the Page_Error event. Application_Error and Page_Error methods are called if an unhandled exception occurs anywhere in your page or application.

You can also use the Page class property ErrorPage that gets or sets the error page to which the requesting browser is redirected in the event of an unhandled page exception.
It works only when customErrors mode is on in Web.Config or Machine.Config.

The sub-element error of customErrors element in Web.Config can be used to define one custom error redirect associated with an HTTP status code and

defaultRedirect attribute is used to specify the default URL to direct a browser to if an error occurs. When defaultRedirect is not specified, a generic error is displayed instead.

  1. How can you handle UnManaged Code Exceptions in ASP.NET?

Unmanaged code can include both C++-style SEH Exceptions and COM-based HRESULTS.

COM handles errors through HRESULT. If an exception occurs in unmanaged code, the COM HRESULT is mapped to the appropriate exception class, which is returned to .NET, where it can be handled like any other exception.

User-defined exception classes can specify whatever HRESULT is appropriate. These exception classes can dynamically change the HRESULT to be returned when the exception is generated by setting the HResult field on the exception object. Additional information about the exception is provided to the client through the IErrorInfo interface, which is implemented on the .NET object in the unmanaged process.

  1. What are the Page level transaction and class level transaction?

ASP.NET transaction support allows pages to participate in ongoing Microsoft .NET Framework transactions. Transaction support is exposed via an @Transaction directive that indicates the desired level of support: Required, RequiresNew, Supported, NotSupported, Disabled.

The Transaction attribute is applied at the class level too to indicate that all class methods should be run in the context of a transaction. If an unhandled exception is thrown during the execution of a class method, the transaction is aborted. Otherwise, the transaction is committed.

using System.EnterpriseServices;
[Transaction]
public class TransactionAttribute_Cl : ServicedComponent
{
}

  1. What are different transaction options?

Required - Shares a transaction, if one exists, and creates a new transaction, if necessary.

RequiresNew- Creates the component with a new transaction, regardless of the state of the current context.

Supported- Shares a transaction, if one exists.

NotSupported- Indicates that the object does not run within the scope of transactions. When a request is processed, its object context is created without a transaction, regardless of whether there is a transaction active.

Disabled - Ignores any transaction in the current context.

  1. What is the namespace for encryption?

Ans: System.Security.cryptography;

  1. What is the difference between application and cache variables?

ASP.NET allows you to save values using application state (an instance of the HttpApplicationState class) for each active Web application. Application state is a global storage mechanism accessible from all pages in the Web application and is thus useful for storing information that needs to be maintained between server round trips and between pages.
The memory occupied by variables stored in application state is not released until the value is either removed or replaced.
Application state is a key-value dictionary structure created during each request to a specific URL. You can add your application-specific information to this structure to store it between page requests.
Once you add your application-specific information to application state, the server manages it.

Cache data can persist for a long time, but not across application restarts. It can hold both large and small amounts of data effectively. Also, data can expire based on time set by the application code or other dependencies; this feature is not available in the Application object.

  1. What is the difference between control and component?

Components implement the System.ComponentModel.IComponent interface by deriving from the SystemComponent.Model.Component base class. Component is generally used for an object that is reusable and can interact with other objects. A .NET Framework component additionally provides features such as control over external resources and design-time support.

A control is a component that provides user-interface capabilities. Controls draw themselves and shown in the visual area.
The .NET Framework provides two base classes for controls: one for client-side Windows Forms controls and the other for ASP.NET server controls. These are System.Windows.Forms.Control and System.Web.UI.Control. System.Windows.Forms.Control derives from Component base class and itself provides UI capabilities.
System.Web.UI.Control implements IComponent and provides the infrastructure on which it is easy to add UI functionality.

  1. You have defined one page_load event in ASPx page and same page_load event in code behind, how will program run?
  2. Where would you use an IHttpModule, and what are the limitations of any approach you might take in implementing one?
  3. Can you edit data in the Repeater control? Which template must you provide, in order to display data in Repeater control? How can you provide an alternating color scheme in a repeater control? What property must you set, and what method must you call in your code, in order to bind the data from some source to the repeater?
  4. What is validXML document?

An XML document that references a DTD in a DOCTYPE statement

  1. What is well formedXML document?

An XML document that does not reference a DTD(document type definition)

Tough ASP.NET interview questions

  1. Describe the difference between a Thread and a Process?

A thread is a path of execution that run on CPU, a proccess is a collection of threads that share the same virtual memory. A process have at least one thread of execution, and a thread always run in a process context.

  1. What is a Windows Service and how does its lifecycle differ from a “standard” EXE?

Windows Service applications are long-running applications that are ideal for use in server environments. The applications do not have a user interface or produce any visual output; it is instead used by other programs or the system to perform operations. Any user messages are typically written to the Windows Event Log. Services can be automatically started when the computer is booted. This makes services ideal for use on a server or whenever you need long-running functionality that does not interfere with other users who are working on the same computer. They do not require a logged in user in order to execute and can run under the context of any user including the system. Windows Services are controlled through the Service Control Manager where they can be stopped, paused, and started as needed.

  1. What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memory for the system? How would this affect a system design?

Well since most people are still not using a 64 bit operating system, we are going to keep this discussion limited to a 32bit OS. In the NT Flavor of operating systems, 4GB of memory is available to each process but it is split 50/50 with with the operating system.

So each process has 2GB of memory available for its private use. The other 2GB is used by the operating system, devices, graphics cards, etc.. Keep in mind, the 4GB/2GB size is regardless of how much RAM you have installed.

This would affect system design if you are creating an application that uses very large data structures or applications like mail servers, database management servers etc.. To address the need for more memory space, you can use a /3GB switch which then splits the memory usage from 50/50 to 75/25. Allowing your application to use 3GB of the 4GB available.

  1. What is the difference between an EXE and a DLL?

. An EXE can run independently, whereas DLL will run within an EXE. DLL is an in-process file and EXE is an out-process file

  1. What is strong-typing versus weak-typing? Which is preferred? Why?

Strong type is checking the types of variables as soon as possible, usually at compile time. While weak typing is delaying checking the types of the system as late as possible, usually to run-time. Which is preferred depends on what you want. For scripts & quick stuff you’ll usually want weak typing, because you want to write as much less (is this a correct way to use Ensligh?) code as possible. In big programs, strong typing can reduce errors at compile time.

  1. What are PDBs? Where must they be located for debugging to work?

To debug precompiled components such as business objects and code-behind modules, you need to generate debug symbols. To do this, compile the components with the debug flags by using either Visual Studio .NET or a command line compiler such as Csc.exe (for Microsoft Visual C# .NET) or Vbc.exe (for Microsoft Visual Visual Basic .NET).

Using Visual Studio .NET1. Open the ASP.NET Web Application project in Visual Studio .NET.
2. Right-click the project in the Solution Explorer and click Properties.
3. In the Properties dialog box, click the Configuration Properties folder.
4. In the left pane, select Build.
5. Set Generate Debugging Information to true.
6. Close the Properties dialog box.
7. Right-click the project and click Build to compile the project and generate symbols (.pdb files).

  1. What is cyclomatic complexity and why is it important?

Cyclomatic complexity is a computer science metric (measurement) developed by Thomas McCabe used to generally measure the complexity of a program. It directly measures the number of linearly independent paths through a program’s source code.

The concept, although not the method, is somewhat similiar to that of general text complexity measured by the Flesch-Kincaid Readability Test.

Cyclomatic complexity is computed using a graph that describes the control flow of the program. The nodes of the graph correspond to the commands of a program. A directed edge connects two nodes, if the second command might be executed immediately after the first command. By definition,

CC = E - N + P

where
CC = cyclomatic complexity
E = the number of edges of the graph
N = the number of nodes of the graph
P = the number of connected components.


[1]

  1. What is FullTrust? Do GAC’ed assemblies have FullTrust?

Your code is allowed to do anything in the framework, meaning that all (.Net) permissions are granted. The GAC has FullTrust because it’s on the local HD, and that has FullTrust by default, you can change that using caspol

  1. What does this do? gacutil /l | find /i “about”

This command is used to install strong typed assembly in GAC

  1. Contrast OOP and SOA. What are tenets of each

A. Service Oriented Architecture. In SOA you create an abstract layer that your applications use to access various “services” and can aggregate the services. These services could be databases, web services, message queues or other sources. The Service Layer provides a way to access these services that the applications do not need to know how the access is done. For example, to get a full customer record, I might need to get data from a SGL Server database, a web service and a message queue. The Service layer hides this from the calling application. All the application knows is that it asked for a full customer record. It doesn’t know what system or systems it came from or how it was retrieved.

  1. How does the XmlSerializer work? What ACL permissions does a process using it require?

XmlSerializer requires write permission to the system’s TEMP directory.

  1. Why is catch(Exception) almost always a bad idea?

Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project.

  1. What is the difference between Debug.Write and Trace.Write? When should each be used?

The Debug.Write call won’t be compiled when the DEBUG symbol is not defined (when doing a release build). Trace.Write calls will be compiled. Debug.Write is for information you want only in debug builds, Trace.Write is for when you want it in release build as well. And in any case, you should use something like log4net because that is both faster and better

  1. What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not?

Debug build contain debug symbols and can be debugged while release build doesn’t contain debug symbols, doesn’t have [Contional(”DEBUG”)] methods calls compiled, can’t be debugged (easily, that is), less checking, etc. There should be a speed difference, because of disabling debug methods, reducing code size etc but that is not a guarantee (at least not a significant one)

  1. Contrast the use of an abstract base class against an interface?

In the interface all methods must be abstract, in the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes

  1. What is the difference between a.Equals(b) and a == b?

a=b is used for assigning the values (rather then comparison) and a==b is for comparison.

  1. In the context of a comparison, what is object identity versus object equivalence?

1) two objects are identical if they share same address in memory.two objects are equivalent if they are instances of the same type and every field of the first object matches the fields of another object.

2)object identical have only same instances.object equivalent have fields are same but the different instances only type are same.

  1. How would one do a deep copy in .NET?

System.Array.CopyTo() - Deep copies an Array

  1. What is boxing?

Boxing is an implicit conversion of a value type to the type object
int i = 123; // A value type
Object box = i // Boxing
Unboxing is an explicit conversion from the type object to a value type
int i = 123; // A value type
object box = i; // Boxing
int j = (int)box; // Unboxing

  1. Is string a value type or a reference type?

String is Reference Type.
Value type - bool, byte, chat, decimal, double, enum , float, int, long, sbyte, short,strut, uint, ulong, ushort
Value types are stored in the Stack
Reference type - class, delegate, interface, object, string
Reference types are stored in the Heap

How does the lifecycle of Windows services differ from Standard EXE?

Windows services lifecycle is managed by “Service Control Manager” which is responsible for starting and stopping the service and the applications do not have a user interface or produce any visual output, but “Standard executable” doesn’t require Control Manager and is directly related to the visual output

What are PDBs? Where must they be located for debugging to work?

A program database (PDB) file holds debugging and project state information that allows incrmental linking of a Debug configuration of your program.

The linker creates project.PDB, which contains debug information for the project’s EXE file. The project.PDB contains full debug information, including function prototypes, not just the type information found in VCx0.PDB. Both PDB files allow incremental updates.

Describe the difference between a Thread and a Process?

The operating system creates a process for the purpose of running a program. Each process executes a single program. Processes own resources allocated by the operating system. Resources include memory, file handles, sockets, device handles, and windows. Processes do not share address spaces or file resources except through explicit methods such as inheriting file handles or shared memory segments, or mapping the same file in a shared way.

Threads allow a program to do multiple things concurrently. At least one thread exists within each process. If multiple threads can exist within a process, then they share the same memory and file resources.

what is web.config in .NET?, and what’s the main usage of it?

It is a configuration file for asp.net web applications. It is written in xml.

Inisde web.config file one can have:

Database connections
Session states
Error handling code
Security can also be enforced.

what is Boxing and Unboxing?
Boxing is an implicit conversion of a value type to the type object
int i = 123; // A value type
Object box = i // Boxing
——————————————————————————–
Unboxing is an explicit conversion from the type object to a value type
int i = 123; // A value type
Object box = i; // Boxing
int j = (int)box; // Unboxing

Simple interview questions on Microsoft .NET

  1. Explain assemblies.

Assembly is a single deployable unit that contains information about the implementation of classes, structures and interfaces. it also stores the information about itself called metadata and includes name and verison of the assembly, security information, information about the dependencies and the list of files that constitute the assembly.

Assembly also contains namespaces. In the .Net Framework, applications are deployed in the form of assemblies.

  1. Name some of the languages .NET support?

Some of the languages that are supported by .NET

1. Visual Basic.NET
2. Visual C#
3. Visual C++

  1. ADO.NET features? Benefits? Drawbacks?

Pros
====
ADO.NET is rich with plenty of features that are bound to impress even the most skeptical of programmers. If this weren’t the case, Microsoft wouldn’t even be able to get anyone to use the Beta. What we’ve done here is come up with a short list of some of the more outstanding benefits to using the ADO.NET architecture and the System.Data namespace.

* Performance – there is no doubt that ADO.NET is extremely fast. The actual figures vary depending on who performed the test and which benchmark was being used, but ADO.NET performs much, much faster at the same tasks than its predecessor, ADO. Some of the reasons why ADO.NET is faster than ADO are discussed in the ADO versus ADO.NET section later in this chapter.

* Optimized SQL Provider – in addition to performing well under general circumstances, ADO.NET includes a SQL Server Data Provider that is highly optimized for interaction with SQL Server. It uses SQL Server’s own TDS (Tabular Data Stream) format for exchanging information. Without question, your SQL Server 7 and above data access operations will run blazingly fast utilizing this optimized Data Provider.

* XML Support (and Reliance) – everything you do in ADO.NET at some point will boil down to the use of XML. In fact, many of the classes in ADO.NET, such as the DataSet, are so intertwined with XML that they simply cannot exist or function without utilizing the technology. You’ll see later when we compare and contrast the “old” and the “new” why the reliance on XML for internal storage provides many, many advantages, both to the framework and to the programmer utilizing the class library.

* Disconnected Operation Model – the core ADO.NET class, the DataSet, operates in an entirely disconnected fashion. This may be new to some programmers, but it is a remarkably efficient and scalable architecture. Because the disconnected model allows for the DataSet class to be unaware of the origin of its data, an unlimited number of supported data sources can be plugged into code without any hassle in the future.

* Rich Object Model – the entire ADO.NET architecture is built on a hierarchy of class inheritance and interface implementation. Once you start looking for things you need within this namespace, you’ll find that the logical inheritance of features and base class support makes the entire system extremely easy to use, and very customizable to suit your own needs. It is just another example of how everything in the .NET framework is pushing toward a trend of strong application design and strong OOP implementations.

Cons
====
Hard as it may be to believe, there are a couple of drawbacks or disadvantages to using the ADO.NET architecture. I’m sure others can find many more faults than we list here, but we decided to stick with a short list of some of the more obvious and important shortcomings of the technology.

* Managed-Only Access – for a few obvious reasons, and some far more technical, you cannot utilize the ADO.NET architecture from anything but managed code. This means that there is no COM interoperability allowed for ADO.NET. Therefore, in order to take advantage of the advanced SQL Server Data Provider and any other feature like DataSets, XML internal data storage, etc, your code must be running under the CLR.

* Only Three Managed Data Providers (so far) – unfortunately, if you need to access any data that requires a driver that cannot be used through either an OLEDB provider or the SQL Server Data Provider, then you may be out of luck. However, the good news is that the OLEDB provider for ODBC is available for download from Microsoft. At that point the down-side becomes one of performance, in which you are invoking multiple layers of abstraction as well as crossing the COM InterOp gap, incurring some initial overhead as well.

* Learning Curve – despite the misleading name, ADO.NET is not simply a new version of ADO, nor should it even be considered a direct successor. ADO.NET should be thought of more as the data access class library for use with the .NET framework. The difficulty in learning to use ADO.NET to its fullest is that a lot of it does seem familiar. It is this that causes some common pitfalls. Programmers need to learn that even though some syntax may appear the same, there is actually a considerable amount of difference in the internal workings of many classes. For example (this will be discussed in far more detail later), an ADO.NET DataSet is nothing at all like a disconnected ADO RecordSet. Some may consider a learning curve a drawback, but I consider learning curves more like scheduling issues. There’s a learning curve in learning anything new; it’s just up to you to schedule that curve into your time so that you can learn the new technology at a pace that fits your schedule.

  1. How many types of exception handlers are there in .NET?

1. Unstructured Exception Handling
2. Strutured Exception Handling

  1. What is the base class of Button control?

Listing from visual studio .net > Button Class

System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.ButtonBase
System.Windows.Forms.Button

  1. What is Response object? How is it related to ASP’s Response object?

Response object allows the server to communicate with the client(browser). It is useful for displaying information to the user (or) redirecting the client.
Eg: Response.Write(”Hello World”)

  1. What is IIS? Have you used it?

IIS - Internet Information Server

IIS is used to access the ASP.Net web applications

Yes, I used in ASP.NET web applications.

  1. Main differences between ASP and ASP.NET.

asp contains scrips which are not compiled
where as in asp.net the code is compiled

Q) What are assemblies ?

ANSWER:An assembly is a single deployable unit that contains all the information about the implementation of :

- classes
- structures and
- interfaces

An assembly stores all the information about itself. This information is called METADATA and include the name and the verison number of the assembly, security information, information about the dependencies and a lost of files that constitute the assembly.

All the application developed using the .NET framework are made up of assemblies.

Namespaces are also stored in assemblies

What is the difference between server side cookies and client side cookies??

Why The JavaScript Validation Not Run on the Asp.Net Button But Run SuccessFully On The HTML Button

Ans. The Asp.Net Button Is post backed on the server & not yet Submit & when It goes to the server its states is lost So if we r using javascript in our application so we always use the Input Button in the asp Button

what is the difference between user control an custom control?
advantages/disadvantages?

Web user controls Vs Web custom controls
Easier to create Vs Harder to create
Limited support for consumers who use a visual design tool Vs Full visual design tool support for consumers
A separate copy of the control is required in each application Vs Only a single copy of the control is required, in the global assembly cache
Cannot be added to the Toolbox in Visual Studio Vs Can be added to the Toolbox in Visual Studio
Good for static layout Vs Good for dynamic layout

What is the use of ErrorProvider Control?

The ErrorProvider control is used to indicate invalid data on a data entry form. Using this control, you can attach error messages that display next to the control when the data is invalid, as seen in the following image. A red circle with an exclamation point blinks, and when the user mouses over the icon, the error message is displayed as a tooltip.

Difference ASP and ASP.NET

1. ASP: Code is Interpreted
ASP.NET: Code is Compiled

2. ASP: Business Logic and Presentation Logic are in a single file
ASP.NET: Business Logic and Presentation Logic are in separate files (.cs or
.vb) and (.aspx) respectively.

3. ASP: No Web Server Controls
ASP.NET: Web Server Controls supported by strong .NET Framework

4. ASP: No RAD in Classic ASP
ASP.NET: Supports RAD

Differences between Asp and Asp.net

1.Asp is interpreted
Asp.net is compiled which is faster than asp.
2 Asp.net maintains its own CLR and is managed as it runs by CLR
Where as asp is unmanaged
3 We can mainatin sessions in state server and sql server which is Outproc,
where in asp sessions will be last if we restart webserver or make changes.
4 In asp.net we can configure each application using web.config file which is availble in application itself and we have machine.config wherer we can configure all applications.
In asp we cannot configure single aplication
5 Asp.net we have autopostback event which is not in asp
6 In asp.net we have global.asax where can hadle some global things which is not in asp.
7 We have well built GUI to work in asp.net
8 We have ado.net and as well as disconnected architecture in asp.net
9 We have Xcopy deployment in asp.net
10. We can work with any language as code behind technique in asp.net that supports .net frame work

What is CLR?
CLR(Common Language Runtime) is the main resource of .Net Framework. it is collection of services like garbage collector, exception handler, jit compilers etc. with the CLR cross language integration is possible.

what are assemblies in .Net :
In the Microsoft .NET framework an assembly is a partially compiled code library for use in deployment, versioning and security. In the Microsoft Windows implementation of .NET, an assembly is a PE (portable executable) file. There are two types, process assemblies (EXE) and library assemblies (DLL). A process assembly represents a process which will use classes defined in library assemblies. In version 1.1 of the CLR classes can only be exported from library assemblies; in version 2.0 this restriction is relaxed. The compiler will have a switch to determine if the assembly is a process or library and will set a flag in the PE file. .NET does not use the extension to determine if the file is a process or library. This means that a library may have either .dll or .exe as its extension.

The code in an assembly is partially compiled into CIL, which is then fully compiled into machine language at runtime by the CLR.

An assembly can consist of one or more files. Code files are called modules. An assembly can contain more than one code module and since it is possible to use different languages to create code modules this means that it is technically possible to use several different languages to create an assembly. In practice this rarely happens, principally because Visual Studio only allows developers to create assemblies that consist of a single code module.

what is the CLR?

The .NET Framework provides a runtime environment which runs the code and provides services that make the development process easier. This runtime environment in .NET Framework is known as Common Language Runtime (CLR). The CLR sits at the very heart of managed code. Common Language Runtime is the generalized multi-language, reflective execution engine on which code originally written in various languages runs. At a higher level, CLR is simply an engine that takes in Intermediate Language (IL) instructions, translates them into machine instructions, and executes them. Although the common language runtime provides many standard runtime services, managed code is never interpreted. A feature called just-in-time (JIT) compiling enables all managed code to run in the native machine language of the system on which it is executing. The CLR shares much in common with a traditional operating system.

Quote:
Managed code is the term used for any code that is running on .NET Framework.

The CLR provides the infrastructure that enables managed code to execute as well provides variety of services during execution. When a method, for which IL has been generated, is called for the first time the CLR compiles the IL into native code that is specific to the processor the Environment it is running on (This process is known as Just in Time Compilation or JIT). If the same method is called next time, the existing JIT compiled code is reused. During execution managed code receives variety of services from the runtime environment.

Quote:
When compiling to managed code, the compiler translates your source code into Microsoft intermediate language (MSIL), which is a CPU-independent set of instructions that can be efficiently converted to native code. Intermediate Language is a binary assembly language that is compiled at runtime down to whatever machine language is appropriate for the host CPU. This runtime compilation is called Just-In-Time Compiling or JIT-compiling.

Advantages of Managed Execution Environments

In unmanaged environments the compiler and linker directly compile the source code in to native instructions that are targeted at a specific processor. The disadvantage of this process is that each time you want to run your executable on a different platform you will have to re-compile the code using a compiler and linker that will compile the code that is targeted at the specific hardware. This means that each time you want your application to run on a different platform, you will have to ship the compiled instructions again and again. As this leads to compiling and maintaining multiple versions of the same application, the companies try to create a more generalized compiled version in order to target most of the environments. This process is known as the Lowest Common Denominator approach. This leads to a more generalized program which is not optimized properly and does not take advantages of the underlying hardware infrastructure (processor, cache, etc). Because the CLR supplies one or more Just in Time Compiler for each computer architecture it supports, the same set of MSIL can be JIT-compiled and run on any supported architecture. This

CLR provides the following benefits for developers:

Vastly simplified development.
Seamless integration of code written in various languages.
Evidence-based security with code identity.
Assembly-based deployment that eliminates DLL Hell.
Side-by-side versioning of reusable components.
Code reuse through implementation inheritance.
Automatic object lifetime management.
Code access security.
Cross Language Integration.
Self describing objects.
The CLR automatically handles object layout and manages references to objects, releasing them when they are no longer being used. This automatic memory management resolves the two most common application errors, memory leaks and invalid memory references. This process is known as Garbage Collection. The CLR also manages thread execution, code execution, code safety verification, compilation, and other system services.

The CLR is designed for the software of the future, and it also supports software of today and yesterday. Interoperability between managed and unmanaged code provided by CLR helps developers continue to use necessary COM components and DLLs.

2.How is meant by DLL ?

A DLL (Dynamic Link Library) is a file that can be loaded and executed by programs dynamically. Basically it’s an external code repository for programs. Since usually several different programs reuse the same DLL instead of having that code in their own file, this dramatically reduces required storage space. A synonym for a DLL would be library.

We see you write any program in any language(some except)and after create the EXE, If you run that EXE program need some supporting environments that is called as Runtime environment.

I give some examples :

1)JAVA needs JRE(Jave Runtime Environment).

2)VB needs VBRUN and msvbvm60.dll.

3).NET needs CLR.

If your program run on other computer you must install
the particular Runtime Environment.

Note: .NET Framework contain the CLR. so when u install the .NET Framework also installed the CLR.
So u run the .NET program,

Your .NET Program + .Net Framework(CLR)=Successfully run on target computer.

Microsoft ASP.NET interview questions

  1. What is an interface and what is an abstract class? Please, expand by examples of using both. Explain why.

Abstract classes are closely related to interfaces. They are classes that cannot be instantiated, and are frequently either partially implemented, or not at all implemented. One key difference between abstract classes and interfaces is that a class may implement an unlimited number of interfaces, but may inherit from only one abstract (or any other kind of) class. A class that is derived from an abstract class may still implement interfaces. Abstract classes are useful when creating components because they allow you specify an invariant level of functionality in some methods, but leave the implementation of other methods until a specific implementation of that class is needed. They also version well, because if additional functionality is needed in derived classes, it can be added to the base class without breaking code.

  1. What is serialization, how it works in .NET?

Serialization is when you persist the state of an object to a storage medium so an exact copy can be re-created at a later stage.

Serialization is used to save session state in ASP.NET.
Serialization is to copy objects to the Clipboard in Windows Forms
Serialization is used by remoting to pass objects by value from one application domain to another

  1. What should one do to make class serializable?

To make a class serializable is to mark it with the Serializable attribute as follows.

[Serializable]
public class MyObject {
public int n1 = 0;
public int n2 = 0;
public String str = null;
}

What exactly is being serialized when you perform serialization?
The object’s state (values)

  1. How does output caching work in ASP.NET?

Output caching is a powerful technique that increases request/response throughput by caching the content generated from dynamic pages. Output caching is enabled by default, but output from any given response is not cached unless explicit action is taken to make the response cacheable.

To make a response eligible for output caching, it must have a valid expiration/validation policy and public cache visibility. This can be done using either the low-level OutputCache API or the high-level @ OutputCache directive. When output caching is enabled, an output cache entry is created on the first GET request to the page. Subsequent GET or HEAD requests are served from the output cache entry until the cached request expires.

The output cache also supports variations of cached GET or POST name/value pairs.

The output cache respects the expiration and validation policies for pages. If a page is in the output cache and has been marked with an expiration policy that indicates that the page expires 60 minutes from the time it is cached, the page is removed from the output cache after 60 minutes. If another request is received after that time, the page code is executed and the page can be cached again. This type of expiration policy is called absolute expiration - a page is valid until a certain time.

  1. What is connection pooling and how do you make your application use it?
  2. Opening database connection is a time consuming operation.
    Connection pooling increases the performance of the applications by reusing the active database connections instead of create new connection for every request.
    Connection pooling Behaviour is controlled by the connection string parameters.
    Follwing the the 4 parameters that control most of the connection pooling behaviour.
    1. Connect Timeout
    2. Max Pool Size
    3. Min Pool Size
    4. Pooling
    Top of Form

Abstract vs Interface.
All abstract methods are virtual by default. They have to be overriden.
Interface methods are not virtual by default. When you are implementing an interface method you can decide whether you want it to be virtual or not.

What is serialization, how it works in .NET?

What should one do to make class serializable?

What is Viewstate?
A server control’s view state is the accumulation of all its property values. In order to preserve these values across HTTP requests, ASP.NET server controls use this property, which is an instance of the StateBag class, to store the property values.

Can any object be stored in a Viewstate?
An object that either is serializable or has a TypeConverter defined for it can be persisted in ViewState

What should you do to store an object in a Viewstate?
Do serialization of convert the object to string

Explain how Viewstate is being formed and how it’s stored on client.

The type of ViewState is System.Web.UI.StateBag, which is a dictionary that stores name/value pairs. ViewState is persisted to a string variable by the ASP.NET page framework and sent to the client and back as a hidden variable. Upon postback, the page framework parses the input string from the hidden variable and populates the ViewState property of each control. If a control uses ViewState for property data instead of a private field, that property automatically will be persisted across round trips to the client. (If a property is not persisted in ViewState, it is good practice to return its default value on postback.)

What do you know about ADO.NET’s objects and methods?

ADO.NET provides consistent access to data sources such as Microsoft SQL Server, as well as data sources exposed through OLE DB and XML.

Data-sharing consumer applications can use ADO.NET to connect to these different data sources and retrieve, manipulate, and update data.

ADO.NET provides first-class support for the disconnected, n-tier programming environment for which many new applications are written.

Explain DataSet.AcceptChanges and DataAdapter.Update methods.

DataAdapter.Update method Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the DataSet.

DataSet.AcceptChanges method Commits all the changes made to this row since the last time AcceptChanges was called.

What is an interface and what is an abstract class? Please, expand by examples of using both. Explain why.

Abstract Classes

An abstract class is the one that is not used to create objects. An abstract class is designed to act as a base class (to be inherited by other classes). Abstract class is a design concept in program development and provides a base upon which other classes are built. Abstract classes are similar to interfaces. After declaring an abstract class, it cannot be instantiated on it’s own, it must be inherited. Like interfaces, abstract classes can specify members that must be implemented in inheriting classes. Unlike interfaces, a class can inherit only one abstract class. Abstract classes can only specify members that should be implemented by all

What is an Abstract class?
An abstract class is a special kind of class that cannot be instantiated. So the question is why we need a class that cannot be instantiated? An abstract class is only to be sub-classed (inherited from). In other words, it only allows other classes to inherit from it but cannot be instantiated. The advantage is that it enforces certain hierarchies for all the subclasses. In simple words, it is a kind of contract that forces all the subclasses to carry on the same hierarchies or standards.

What is an Interface?
An interface is not a class. It is an entity that is defined by the word Interface. An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body. As one of the similarities to Abstract class, it is a contract that is used to define hierarchies for all subclasses or it defines specific set of methods and their arguments. The main difference between them is that a class can implement more than one interface but can only inherit from one abstract class. Since C# doesn’t support multiple inheritance, interfaces are used to implement multiple inheritance.

Response.Redirect
The Response.Redirect method causes the browser to connect to a specified URL. When the Response.Redirect() method is called, it creates a response whose header contains a 302 (Object Moved) status code and the target URL. When the browser receives this response from the server, it uses this header information to generate another HTTP request to the new URL. When using the Response.Redirect method, the redirection happens at the client side and involves two round trips to the server: one to request the original page, which is met by the 302 response, and then a second to request the redirected page.

What are different methods of session maintenance in ASP.NET?

3 types:

In-process storage.
Session State Service.
Microsoft SQL Server.

In-Process Storage
The default location for session state storage is in the ASP.NET process itself.

Session State Service
As an alternative to using in-process storage for session state, ASP.NET provides the ASP.NET State Service. The State Service gives you an out-of-process alternative for storing session state that is not tied quite so closely to ASP.NET’s own process.

To use the State Service, you need to edit the sessionState element in your ASP.NET application’s web.config file:

You’ll also need to start the ASP.NET State Service on the computer that you specified in the stateConnectionString attribute. The .NET Framework installs this service, but by default it’s set to manual startup. If you’re going to depend on it for storing session state, you’ll want to change that to automatic startup by using the Services MMC plug-in in the Administrative Tools group.

If you make these changes, and then repeat the previous set of steps, you’ll see slightly different behavior: session state persists even if you recycle the ASP.NET process.

There are two main advantages to using the State Service. First, it is not running in the same process as ASP.NET, so a crash of ASP.NET will not destroy session information. Second, the stateConnectionString that’s used to locate the State Service includes the TCP/IP address of the service, which need not be running on the same computer as ASP.NET. This allows you to share state information across a web garden (multiple processors on the same computer) or even across a web farm (multiple servers running the application). With the default in-process storage, you can’t share state information between multiple instances of your application.

The major disadvantage of using the State Service is that it’s an external process, rather than part of ASP.NET. That means that reading and writing session state is slower than it would be if you kept the state in-process. And, of course, it’s one more process that you need to manage. As an example of the extra effort that this can entail, there is a bug in the initial release of the State Service that allows a determined attacker to crash the ASP.NET process remotely. If you’re using the State Service to store session state, you should install the patch from Microsoft Security Bulletin MS02-66, or install SP2 for the .NET Framework.

Microsoft SQL Server
The final choice for storing state information is to save it in a Microsoft SQL Server database. To use SQL Server for storing session state, you need to perform several setup steps:

Run the InstallSqlState.sql script on the Microsoft SQL Server where you intend to store session state. This script will create the necessary database and database objects. The .NET Framework installs this script in the same folder as its compilers and other tools–for example, C:\WINNT\Microsoft.NET\Framework\v1.0.3705 on a Windows 2000 computer with the 1.0 version of the Framework.
Edit the sessionState element in the web.config file for your ASP.NET application as follows:

Supply the server name, user name, and password for a SQL Server account that has access to the session state database in the sqlConnectionString attribute.
Like the State Service, SQL Server lets you share session state among the processors in a web garden or the servers in a web farm. But you also get the additional benefit of persistent storage. Even if the computer hosting SQL Server crashes and is restarted, the session state information will still be present in the database, and will be available as soon as the database is running again. That’s because SQL Server, being an industrial-strength database, is designed to log its operations and protect your data at (almost) all costs. If you’re willing to invest in SQL Server clustering, you can keep the session state data available transparently to ASP.NET even if the primary SQL Server computer crashes.

Like the State Service, SQL Server is slower than keeping session state in process. You also need to pay additional licensing fees to use SQL Server for session state in a production application. And, of course, you need to worry about SQL Server-specific threats such as the “Slammer” worm.

What is Smart Navigation ?

Ans : Is the attribute of the page tag which allows the browser to sections of the form that have changed. The advantage of Smart Navigation is that the screen does not flash as it updated, instead, the scroll postion is maintained and the “last page” in the history is maintained. It is only availabe to the users with Microsoft Internet Explorer 5 or later.

Q: when we go for html server controls and when we go for web server controls?
A: Server controls are a part of ASP.net. When a server control is used there will be an extra overhead on the server to create the control at runtime and accordingly set the values. HTML controls are static controls and are easy to use. They are supported is ASP.net.
As a rule, if there is a correspoding HTML control available instead of the server control, you should always go for the HTML control as it enhances the server performance and ensures faster response.
Server controls should be used when it is found that the available HTML controls are not sufficient to achieve the task.

difference between asp and asp.net

1. ASP is mostly written using VB Script and HTML intermixed. Presentation and business logic is intermixed while ASP.NET can be writen in several .NET compliant languages like C#, VB.NET and business logic can be clearly separated from Presentation logic.
2. ASP had maximum of 4 built in classes like Request, Response, Session and Application whereas ASP.NET using .NET framework classes which has more than 2000 in built classes.
3. ASP does not have any server based components whereas ASP.NET offers several server based components like Button, TextBox etc and event driven processing can be done at server.
4. ASP did not support Page level transactions whereas ASP.NET supports Page level transactions.
5. ASP.NET offers web development for mobile devices which alters the content type (wml or chtml etc) based on the device.
6. ASP.NET uses languages which are fully object oriented languages like c# and also supports cross language support.
7. ASP.NET offers support for Web Services and rich data structures like DataSet which allows disconnected data processing.

What is the difference between a DLL and an EXE?

In .NET, an assembly may become a DLL or an EXE. Yet, there is a major underlying difference between the two.
An EXE is an executable file, that may run on its own. Its independant. Where as a DLL is a Dynamic Link Library, that binds to an exe, or another DLL at runtime.
A DLL has an exposed interface, through which members of the assembly may be accessed by those objects that require it.
A DLL runs in tandem with the application space in memory, as the application references it. Whereas an EXE is independant, and runs as an independant process.

Comments

Popular posts from this blog

All about SSP in MOSS 2007

Request.QueryString() for Javascript (ver. 1.41)