m .Net Technologies Interviews Questions(asp.net,vb.net,c#.net)
Login(Email) Password Forgot Password Account Settings
Home ASP.net System Info C# Books Java Script Visual C++(MFC) C/C++ Win API Java Contact Us
.Net Technologies Interview Question
If I’m developing an application that must accommodate multiple security levels though secure login and my ASP.NET web application is spanned across three web-servers (using round-robin load balancing) what would be the best approach to maintain login-in state for the users?
You can use the security state maintained using a database. (Use Authentication mode as database)
What’s the difference between CodeFile="MyCode.aspx.cs" and Src="MyCode.aspx.cs"?
Visual Studio uses the CodeFile attribute to distinguish the page source or programming logic from the design. Also the src attribute will make the page compile on every request. That is the page will not be compiled in advance and stored in the bin as a dll instead it will be compiled at run time.
Suppose you want a certain ASP.NET function executed on MouseOver over a certain button or textbox. Where do you add an event handler?
Every web control has a ability to add the attributes on client side which will execute on client side and run a client side script like a javascript function.

btnSubmit.Attributes.Add(“onMouseOver”,”someClientCode();”) //For on mouse over of a button
TextBox1.Attributes.Add(“onFocus”,“ClearText();”) //For on focus of a text box

Explain what a diffgram is and a good use for one?
The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. For reading database data to an XML file to be sent to a Web Service.
What base class do all Web Forms inherit from?
The Page class.
Name two properties common in every validation control?
ControlToValidate and Text property.
What tags do you need to add within the Datagrid tags to bind columns manually?
Set AutoGenerateColumns Property to false on the Datagrid tag.
What tag do you use to add a hyperlink column to the DataGrid?>
asp:HyperLinkColumn
What is the transport protocol you use to call a Web service?
SOAP (Simple Object Access Protocol) is the preferred protocol.
Which control would you use if you needed to make sure the values in two different controls matched?
CompareValidator Control
What are the assembly entry points? An Assembly can have how many entry points at a time?
An assembly can have only one entry point from DllMain, WinMain or Main.
What does an assembly contain?
  • Manifest - The metadata describing the information below. Assembly
  • name - Aids in versioning and visibility scope. Version
  • information - The version number is integrated into the assembly's identity.
  • Types - Boundaries and scopes of methods, classes, properties, events, attributes.
  • Locale - Information describing language/culture.
  • Cryptographic Hash - Public key encoded hash acting as version/security check.
  • Security Permissions - The permissions within the assembly determine the permissions that can be granted for all aspects of the assembly contents.
What does an assembly manifest contains?
It contains assembly name, version number (major.minor.build.revision) and culture Information. It also specifies the strong name information, which is useful for shared assemblies, and list of files, an assembly contains. It also provides information for type references in an assembly and other referenced assemblies.
Which tool is used to deploy an assembly, so as the assembly is available to all the application?
The GacUtil.exe is the tool, which allows us to add any assembly to the windows GAC.
How many catch statements can be associated with single try statement?
There can be a zero or more catch statement for each try statement. So it has not limit to the number of catch statement per try statement
What is Console and System a Class/a Data Member/a routine/a namespace or a type?
Console is a class and System is namespace.
How many values can be returned from a method in C#?
Only one value can be returned from method, however you can use ref or out variable to change more than one value in called method.
How to declare a variable named this in C#, with data type string?
string @this;
Can we change the dimension of Array at run time like Array [3, 4]?
Yes, We can change only the first position of array dimension.
What keyword is used to accept a variable number of parameter in a method?
“params” keyword is used as to accept variable number of parameters.
What is a Namespace? What is the use of a namespace?
Namespaces are logical grouping of classes and other types in hierarchical structure. Namespaces are useful to avoid collision or ambiguity among the classes and type names. Another use of the namespace is to arrange a group of classes for a specific purpose.
What does a keyword using works for?
Using is just a convention or a short-cut method which allows us to access the classes in a namespace by referencing it once. So when ever we want use the classes or methods in them, we can avoid typing the entire namespace hierarchy. However it is not a good practice when there are likely chances to have name ambiguity or collision of class names.
What is Enums in C#?
Enums or Enumerators are used to declare a set of related constants (default start with 0); they are only available with primitive data types like int and short etc.
What is Delegates?
Delegates are a type-safe, object-oriented implementation of function pointers and are used in many situations where a component needs to call back to the component that is using it. Delegates are generally used as basis of events, which allow any delegate to easily be registered for as event.
Which are the namespaces that are imported automatically by Visual Studio in ASP.Net?
There are 7 namespaces which are imported automatically.
  • System
  • System.Collections
  • System.IO
  • System.web
  • System.web.UI
  • System.web.UI.HTMLControls
  • System.web.UI.WebControls
Which namespaces are used for data access?
  • System.Data
  • System.Data.OleDB
  • System.Data.SQLClient
What do you mean by boxing and un-boxing?
C# provides us with Value types and Reference Types. Value Types are stored on the stack and Reference types are stored on the heap. The conversion of value type to reference type is known as boxing and converting reference type back to the value type is known as un-boxing.

e.g.
int x = 10;

object o = x ; // Implicit boxing
object o = (object) x; // Explicit Boxing

x = o; // Implicit Un-Boxing
x = (int)o; // Explicit Un-Boxing

What are the different methods available under sqlcommand class to access the data?
  • ExecuteReader –Used where one or more records are returned -SELECT Query.
  • ExecuteNonQuery – Used where it affects a state of the table and no data is being queried-  INSERT, UPDATE, DELETE, CREATE and SET queries.
  • ExecuteScalar – Used where it returns a single record(a single value normally) – SQL Functions like MIN(), NAX()
What are the different types of Session state management options available with ASP.NET?
ASP.NET provides In-Process & Out-of-Process state management,
Also known as "In-Proc" and "Out-Proc". In-Proc stores the session in memory of the web server, that is on the same server the ASP.Net page is.
On the other hand Out-Proc session state management stores the session data on external data source, which can be a SQL Server or Server State Service. Out-of-Process state management requires the objects stored in session, must be serializable.
What is Remoting? Give Example.
Remoting is a means by which one operating system process, or program, can communicate with another process. The two processes can exist on the same computer or on two computers connected by a LAN or the Internet. Web services are probably the best known type of remoting, but they are not the only option
What is Marshalling?
Marshaling is a process of making an object in one process (the server) available to another process (the client). There are two ways to achieve the marshalling.

i. Marshal by value: the server creates a copy of the object passes the copy to the client. When a client makes a call to an object marshaled by value (MBV), the server creates an exact copy and sends that copy to the client. The client can then use the object's data and executable functionality directly within its own process or application domain without making additional calls to the server. Objects that the application accesses frequently are best remoted using MBV.

ii. Marshal by reference: the client creates a proxy for the object and then uses the proxy to access the object. When a client makes a call to an object marshaled by reference (MBR), the .NET framework creates a proxy in the client's application domain and the client uses that proxy to access the original object on the server. Large objects that the application accesses relatively infrequently are good candidates for MBR.
What is a Static class? What are its features?
Static class is a class which can be used or accessed without creating an instance of the class.
Important Features: Static class only contains static members and a private constructor. Static class cannot be instantiated. iii. Static classes are sealed by default and therefore cannot be inherited.
What is sealed class? What are its features?
Sealed classes are those classes which can not be inherited and thus any sealed class member can not be derived in any other class. A sealed class cannot also be an abstract class.
In C# structs are implicitly sealed; therefore, they cannot be inherited.
Can we declare a method as sealed?
In C# a method can't be declared as sealed. However when we override a method in a derived class, we can declare the overridden method as sealed. By declaring it as sealed, we can avoid further overriding of this method.

E.g.
using System;
class MyClass1
{
public int x;
public int y;
public virtual void Method()
{
Console.WriteLine("virtual method");
}
} class MyClass : MyClass1
{
public override sealed void Method()
{ Console.WriteLine("sealed method");
}
}
class MainClas
{
public static void Main()
{
MyClass1 mC = new MyClass();
mC.x = 110; mC.y = 150;
Console.WriteLine("x = {0}, y = {1}", mC.x, mC.y); mC.Method();
}
}

What is a DataSet ?
A DataSet is an in memory representation of data loaded from any data source.
What is a DataTable?
A DataTable is a class in .NET Framework and in simple words a DataTable object represents a table from a database.
If you want to view an Assembly how to you go about it? What is ILDASM?
You can use the MSIL Disassembler (Ildasm.exe) to view Microsoft intermediate language (MSIL) information in a file. If the file being examined is an assembly, this information can include the assembly's attributes, as well as references to other modules and assemblies. This information can be helpful in determining whether a file is an assembly or part of an assembly, and whether the file has references to other modules or assemblies.
Where is version information stored of an assembly?
The version number is stored in the assembly manifest along with other identity information, including the assembly name and public key, as well as information on relationships and identities of other assemblies connected with the application.
Is versioning applicable to private assemblies?
No
How to create a shared assembly or add an assembly to GAC?
There are several ways an assembly can be added to GAC. i. Use .msi installer designed to work with the global assembly cache. ii. Use GACUtil.exe provided by the .NET Framework SDK. iii. Use Windows Explorer to drag assemblies into the cache.
What is reflection?
All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly. Reflection is ability to find information about types contained in an assembly at run time.
How can I produce an assembly?
Simply compile your class/module with the following command.
C#.Net - CSC /t:library yourclassname.cs
VB.Net - VBC /t:library yourmodulename.vb
What is an Application Domain? How they get created?
An Application Domain can be thought of as a lightweight processes controlled by the .Net runtime. Application Domains are usually created by hostslike Windows Shell, ASP.NET and IE. When you run a .NET application from the command-line, the host is the Shell. The Shell creates a new Application Domain for every application.
Do I have any control over the garbage collection algorithm?
Yes, we have a limited control over the GC algorithm, For example, the System.GC class exposes a Collect method - this forces the garbage collector to collect all unreferenced objects immediately.
What is a life span of a static variable?
A static variable’s life span is till the class is in memory.
What is a Page Life Cycle of an ASP.Net page?
There are various stages described as under. Init LoadViewState LoadPostBackData Load RaisePostBackDataChangedEvent RaisePostBackEvents Pre-Render SaveViewState Render Unload
Can the action attribute of a server-side <form>tag be set to a value and if not how can you possibly pass data from a form to a subsequent Page?
No, Assigning value will not work because will be overwritten at the time of rendering. We can assign value to it by register a startup script which will set the action value of form on client-side. On other hand we can use Server.Transfer or Response.Redirect
How do you turn off cookies in one page of your asp.net application?
We may not use them at the max, However to allow the cookies or not, is client side functionality.
Which method do you use to redirect to user to another page without performing a round trip to Client?
Server.Transfer(“AnotherPage.aspx”).
How many namespaces are in .NET version 1.1?
124
Should Validation occur on Client/Server Side for Date Input?
Both. Client-side reduces extra round-trip. Server-Side ensures prevention against hacking and failure against automated requests.
What are the web form events?
i. The first event that occurs in the life of a Web Form is the Init event. This is raised so that we can have initialization code for the page. The controls on the page are not yet created at this point. This event is raised once for each user of the page. ii. The Load event follows the Init event. Subsequently, it is raised each time the page is requested. When this event is raised, all child controls of the Web Form are loaded and accessible. You should be able to retrieve data and populate the controls so that they can render themselves on the page when sent back to the client. iii. The PreRender event happens just before the page is rendered and sent back to the client. We don't often handle this event; however, it depends on the situation. iv The last event in the life of a Web Form is the Unload event. This happens when the page is unloaded from memory. Final cleanup should be done here.
Previous Next