0% found this document useful (0 votes)
120 views25 pages

What Is Namespace?: Appdomain

A namespace is a group of classes, structures, interfaces, enumerations, and delegates. Each namespace in the FCL can contain multiple namespaces. The CLR is language-neutral, which means it can run code written in any language.

Uploaded by

Arun Kollam
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views25 pages

What Is Namespace?: Appdomain

A namespace is a group of classes, structures, interfaces, enumerations, and delegates. Each namespace in the FCL can contain multiple namespaces. The CLR is language-neutral, which means it can run code written in any language.

Uploaded by

Arun Kollam
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 25

1. What is Namespace?

Namespace is a group of classes, structures, interfaces, enumerations, and delegates, organized in a logical
hierarchy by function, that enable you to access the core functionality you need in your applications.
Namespaces are the way that .NET avoids name clashes between classes. A namespace is no more than a
grouping of data types, but it has the effect that the names of all data types within a namespace automatically
get prefixed with the name of the namespace. It is also possible to nest namespaces within each other.
Each namespace in the FCL can contain multiple namespaces, or they can contain classes that expose
properties and methods that you call in your applications. The namespaces within the FCL are grouped by
the functionality they provide, which makes it very easy to find what you're looking for.

2. How does the code written in different languages get executed in .net?
The CLR is language-neutral, which means that it can run code written in C#, Visual Basic.NET, Visual C+
+, Visual J#, Net COBOL, RPG.NET, or any other language, as long as that language is first compiled to the
bytestream format the CLR expects. When compiling to managed code, the language-specific compiler
translates the source code into Microsoft Intermediate Language (MSIL), which is a CPU-independent set of
instructions that can be efficiently converted to native code. MSIL includes instructions for loading, storing,
initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations,
control flow, direct memory access, exception handling, and other operations. The compiled MSIL is placed
into an EXE or DLL file, called a Portable Executable (PE) file.
Before code can be run, the MSIL in the PE must be converted to CPU-specific code, by a CPU-specific
just-in-time (JIT) compiler. Because the Common Language Runtime supplies one or more JIT compilers
for each computer-processor instruction architecture it supports, the same set of MSIL can be JIT-compiled
and run on any supported architecture for example, Itanium, x64, or x86. During execution, managed code
receives services such as garbage collection, security, interoperability with unmanaged code, cross-language
debugging support, and enhanced deployment and versioning support from the CLR .

3. What is an application domain?


An application domain (often AppDomain) is a virtual process that serves to isolate an application. All
objects created within the same application scope (in other words, anywhere along the sequence of object
activations beginning with the application entry point) are created within the same application domain.
Multiple application domains can exist in a single operating system process, making them a lightweight
means of application isolation.
An OS process provides isolation by having a distinct memory address space. While this is effective, it is
also expensive, and does not scale to the numbers required for large web servers. The Common Language
Runtime (CLR), on the other hand, enforces application isolation by managing the memory use of code
running within the application domain. This ensures that it does not access memory outside the boundaries
of the domain. It is important to note that only type-safe code can be managed in this way (the runtime
cannot guarantee isolation when unsafe code is loaded in an application domain).

4. What are Generics in .Net framework 2.0?


Generics are related to the idea of Templates in C++. They permit classes, structs, interfaces, delegates, and
methods to be parameterized by the types of data they store and manipulate. Without generics, general
purpose methods or data structures (like Lists, Stacks, etc.) typically use the built-in Object type to store data
of any type. While the use of the built-in Object type makes the implementation very flexible, it has
drawbacks with regards to Performance and Type Safety.

For example, it is possible to use any user defined type, e.g. TeacherClass, as a parameter in calls to these
general purpose classes. However, the general purpose data structures cannot be sure that the type passed in
is what is expected. If it is not, it frequently results in ugly runtime errors in the application. Also, if the type
is returned from the method call after processing, the result must explicitly be cast back to the appropriate
type, which adds further overhead. Generics provide a way to create strongly typed parameters, allowing
reuse of the general purpose routine without the associated type safety issues and the overhead of run-time
type checking. Generics are available to any .NET language in the .NET Framework 2.0.

5. What is an assembly in .NET Framework?


An assembly is the primary building block of a .NET Framework application. It is a collection of
functionality that is built, versioned, and deployed as a single implementation unit (as one or more files). All
managed types and resources are marked either as accessible only within their implementation unit, or as
accessible by code Outside that unit.Assemblies are self-describing by means of their manifest, which is an
integral part of every assembly. The manifest:

Establishes the assembly identity (in the form of a text name), version, culture, and digital signature (if the
assembly is to be shared across applications).
• Defines what files (by name and file hash) make up the assembly implementation.
• Specifies the types and resources that make up the assembly, including which are exported from the
assembly.
• Itemizes the compile-time dependencies on other assemblies.
• Specifies the set of permissions required for the assembly to run properly.
• This information is used at run time to resolve references, enforce version binding policy, and
validate the integrity of loaded assemblies. The runtime can determine and locate the assembly for
any running object, since every type is loaded in the context of an assembly. Assemblies are also the
unit at which code access security permissions are applied. The identity evidence for each assembly
is considered separately when determining what permissions to grant the code it contains.
The self-describing nature of assemblies also helps makes zero-impact install and XCOPY deployment
feasible.

6. What is assembly manifest?


Every assembly, whether static or dynamic, contains a collection of data that describes how the elements in
the assembly relate to each other. The assembly manifest contains this assembly metadata. An assembly
manifest contains all the metadata needed to specify the assembly's version requirements and security
identity, and all metadata needed to define the scope of the assembly and resolve references to resources and
classes. The assembly manifest can be stored in either a PE file (an .exe or .dll) with Microsoft intermediate
language (MSIL) code or in a standalone PE file that contains only assembly manifest information.
For an assembly with one associated file, the manifest is incorporated into the PE file to form a single-file
assembly. You can create a multi-file assembly with a standalone manifest file or with the manifest
incorporated into one of the PE files in the assembly.

7. Explain the information stored in assembly manifest.


Assembly manifest contains the following information:
Assembly name -A text string specifying the assembly's name.
Version number- A major and minor version number, and a revision and build number. The common
language runtime uses these numbers to enforce version policy.
Culture- Information on the culture or language the assembly supports. This information should be used
only to designate an assembly as a satellite assembly containing culture- or language-specific information.
(An assembly with culture information is automatically assumed to be a satellite assembly.)
Strong name information- The public key from the publisher if the assembly has been given a strong name.
List of all files in the assembly- A hash of each file contained in the assembly and a file name. Note that all
files that make up the assembly must be in the same directory as the file containing the assembly manifest.
Type reference information -Information used by the runtime to map a type reference to the file that
contains its declaration and implementation. This is used for types that are exported from the assembly.
Information on referenced assemblies -A list of other assemblies that are statically referenced by the
assembly. Each reference includes the dependent assembly's name, assembly metadata (version, culture,
operating system, and so on), and public key, if the assembly is strong named.
You can add or change some information in the assembly manifest by using assembly attributes in your
code. You can change version information and informational attributes, including Trademark, Copyright,
Product, Company, and Informational Version. Every assembly, whether static or dynamic, contains a
collection of data that describes how the elements in the assembly relate to each other. The assembly
manifest contains this assembly metadata. An assembly manifest contains all the metadata needed to specify
the assembly's version requirements and security identity, and all metadata needed to define the scope of the
assembly and resolve references to resources and classes. The assembly manifest can be stored in either a PE
file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a standalone PE file that
contains only assembly manifest information. For an assembly with one associated file, the manifest is
incorporated into the PE file to form a single-file assembly. You can create a multi-file assembly with a
standalone manifest file or with the manifest incorporated into one of the PE files in the assembly.
8. What are the functions performed by the assembly manifest?
Each assembly's manifest performs the following functions:
• Enumerates the files that make up the assembly.
• Governs how references to the assembly's types and resources map to the files that contain their
declarations and implementations. Enumerates other assemblies on which the assembly depends.
• Provides a level of indirection between consumers of the assembly and the assembly's
implementation details.
• Renders the assembly self-describing.

9. Where are shared assemblies stored?
Shared assemblies are stored in Global assembly cache (GAC).

10. What is GAC (Global Assembly Cache)?


Each computer where the common language runtime is installed has a machine-wide code cache called the
global assembly cache that stores assemblies specifically designated to be shared by several applications on
the computer.
You should share assemblies by installing them into the global assembly cache only when you need to. As a
general guideline, keep assembly dependencies private, and locate assemblies in the application directory
unless sharing an assembly is explicitly required. In addition, it is not necessary to install assemblies into the
global assembly cache to make them accessible to COM interop or unmanaged code.

Assemblies deployed in the global assembly cache must have a strong name. When an assembly is added to
the global assembly cache, integrity checks are performed on all files that make up the assembly.

11. Where's global assembly cache located on the system?


Shared assemblies are stored in Global assembly cache (GAC) which is usually located at
C:\winnt\assembly or C:\windows\assembly.

12. What are the ways to deploy an assembly into the (GAC) global assembly cache?
There are several ways to deploy an assembly into the global assembly cache:
• Use an installer designed to work with the global assembly cache. This is the preferred option for
installing assemblies into the global assembly cache.
• Use a developer tool called the Global Assembly Cache tool (Gacutil.exe), provided by the .NET
Framework SDK.
• Use Windows Explorer to drag assemblies into the cache.

13. What is the purpose of ILdasm.exe (Intermediate Language Disassembler)?


The ILdasm.exe (Intermediate Language Disassembler) parses any .NET Framework .exe or .dll assembly,
and shows the information in human-readable format. ILdasm.exe shows more than just the Microsoft
intermediate language (MSIL) code it also displays namespaces and types, including their interfaces. You
can use Ildasm.exe to examine native .NET Framework assemblies, such as Mscorlib.dll, as well as .NET
Framework assemblies provided by others or created yourself.
For example to show the detail of your HelloWorld Application use the command
ILdasm HelloWorld.exe

14. What is the difference between a private assembly and a shared assembly?
A private assembly is normally used by a single application, and is stored in the application's directory, or a
sub-directory beneath.
A shared assembly is intended to be used by multiple applications, and is normally stored in the global
assembly cache (GAC), which is a central repository for assemblies.
A shared assembly can also be stored outside the GAC, in which case each application must be pointed to
its location via a codebase entry in the application's configuration file. The main advantage of deploying
assemblies to the GAC is that the GAC can support multiple versions of the same assembly side-by-side.
15. What is the difference between struct and class in C#?
Structs vs classes in C#
Structs may seem similar to classes, but there are important differences that you should be aware of. First of
all, classes are reference types and structs are value types. By using structs, you can create objects that
behave like the built-in types and enjoy their benefits as well.
• When you call the New operator on a class, it will be allocated on the heap. However, when you
instantiate a struct, it gets created on the stack. This will yield performance gains. Also, you will not
be dealing with references to an instance of a struct as you would with classes. You will be working
directly with the struct instance. Because of this, when passing a struct to a method, it's passed by
value instead of as a reference.
• Structs can declare constructors, but they must take parameters. It is an error to declare a default
(parameterless) constructor for a struct. Struct members cannot have initializers. A default
constructor is always provided to initialize the struct members to their default values.
• When you create a struct object using the New operator, it gets created and the appropriate
constructor is called. Unlike classes, structs can be instantiated without using the New operator. If
you do not use New, the fields will remain unassigned and the object cannot be used until all the
fields are initialized.
• There is no inheritance for structs as there is for classes. A struct cannot inherit from another struct
or class, and it cannot be the base of a class. Structs, however, inherit from the base class object. A
struct can implement interfaces, and it does that exactly as classes do,
• Structs are simple to use and can prove to be useful at times. Just keep in mind that they're created on
the stack and that you're not dealing with references to them but dealing directly with them.
Whenever you have a need for a type that will be used often and is mostly just a piece of data, structs
might be a good option.

16. How do I call one constructor from another in C#?


You use : base (parameters) or : this (parameters) just before the actual code for the constructor,
depending on whether you want to call a constructor in the base class or in this class.

17. Comparison Between Properties and Indexers


Indexers are similar to properties. Except for the differences shown in the following , all of the rules defined
for property accessors apply to indexer accessors as well.
Properties Indexers
Identified by its name. Identified by its signature.
Accessed through a simple name or a
Accessed through an element access.
member access.
Can be a static or an instance member. Must be an instance member.
A get accessor of a property has no A get accessor of an indexer has the same formal parameter list as
parameters. the indexer.
A set accessor of a property contains the A set accessor of an indexer has the same formal parameter list as
implicit value parameter. the indexer, in addition to the value parameter.

18. Which interface(s) must a class implement in order to support the foreach statement?
Required interface for foreach statement:
A class must implement the IEnumerable and IEnumerator interfaces to support the foreach statement.

19. Explain Abstract, Sealed, and Static Modifiers in C#.


C# provides many modifiers for use with types and type members. Of these, three can be used with classes:
abstract, sealed and static.
abstract
Indicates that a class is to be used only as a base class for other classes. This means that you cannot create an
instance of the class directly. Any class derived from it must implement all of its abstract methods and
accessors. Despite its name, an abstract class can possess non-abstract methods and properties.
sealed
Specifies that a class cannot be inherited (used as a base class). Note that .NET does not permit a class to be
both abstract and sealed.
static
Specifies that a class contains only static members (.NET 2.0).

20. What's the difference between override and new in C#?


This is all to do with polymorphism. When a virtual method is called on a reference, the actual type of the
object that the reference refers to is used to decide which method implementation to use. When a method of
a base class is overridden in a derived class, the version in the derived class is used, even if the calling code
didn't "know" that the object was an instance of the derived class. For instance:
public class Base
{
public virtual void SomeMethod()
{
}
}

public class Derived : Base


{
public override void SomeMethod()
{
}
}

...

Base b = new Derived();


b.SomeMethod();

will end up calling Derived.SomeMethod if that overrides Base.SomeMethod.

Now, if you use the new keyword instead of override, the method in the derived class doesn't override the
method in the base class, it merely hides it. In that case, code like this:
public class Base
{
public virtual void SomeOtherMethod()
{
}
}
public class Derived : Base
{
public new void SomeOtherMethod()
{
}
}

...

Base b = new Derived();


Derived d = new Derived();
b.SomeOtherMethod();
d.SomeOtherMethod();
Will first call Base.SomeOtherMethod , then Derived.SomeOtherMethod . They're effectively two entirely
separate methods which happen to have the same name, rather than the derived method overriding the base
method.
If you don't specify either new or overrides, the resulting output is the same as if you specified new, but
you'll also get a compiler warning (as you may not be aware that you're hiding a method in the base class
method, or indeed you may have wanted to override it, and merely forgot to include the keyword).

21. Name two ways that you can prevent a class from being instantiated.
Ways to prevent a class from instantiated:
A class cannot be instantiated if it is abstract or if it has a private constructor.

22. Explain some features of interface in C#.


Comparison of interface with class (interface vs class):
• An interface cannot inherit from a class.
• An interface can inherit from multiple interfaces.
• A class can inherit from multiple interfaces, but only one class.
• Interface members must be methods, properties, events, or indexers.
• All interface members must have public access (the default).
• By convention, an interface name should begin with an uppercase I.

23. Can an abstract class have non-abstract methods?


An abstract class may contain both abstract and non-abstract methods. But an interface can contain only
abstract methods.

24. How do I use an alias for a namespace or class in C#?


Use the using directive to create an alias for a long namespace or class. You can then use it anywhere you
normally would have used that class or namespace. The using alias has a scope within the namespace you
declare it in.

Sample code:
// Namespace:
using act = System.Runtime.Remoting.Activation;

// Class:
using list = System.Collections.ArrayList;
...
list l = new list(); // Creates an ArrayList
act.UrlAttribute obj; // Equivalent to System.Runtime.Remoting.Activation.UrlAttribute obj

25. What type of class cannot be inherited?


A sealed class cannot be inherited. A sealed class is used primarily when the class contains static members.
Note that a struct is implicitly sealed; so they cannot be inherited.

26. What keyword must a derived class use to replace a non-virtual inherited method?
new keyword is used to replace (not override) an inherited method with one of the same name.
To know the difference between new and override read: new vs override in C#

27. Explain Web.config Settings for exception management in ASP.NET.


You should configure exception management settings within your application's Web.config file. The
following is an example of the exception settings in a Web.config file.
< customErrors defaultredirect="http://hostname/error.aspx" mode="On"/>
< error statuscode="500" redirect="/errorpages/servererror.aspx" />
< error statuscode="404" redirect="/errorpages/filenotfound.htm" />
< /customErrors>

In the customErrors element, specify a default redirect page. There are three modes for the default redirect
page
On
Unhandled exceptions will redirect the user to the specified defaultredirect page. This is used mainly in
production.
Off
Users will see the exception information and not be redirected to the defaultredirect page. This is used
mainly in development.
RemoteOnly
Only users accessing the site on the local machine (using localhost) will see the exception information while
all other users will be redirected to the defaultredirect page. This is used mainly for debugging.
In addition to the default redirect page, you can set specific pages for certain HTTP error codes. For
example, you can specify that all 404 errors result in a certain error page, while all 500 errors result in
another

28. Why should you avoid the excessive use of ViewState in Asp.Net web page?
Automatic state management is a feature that enables server controls to re-populate their values on a round
trip without requiring you to write any code. This feature is not free however, since the state of a control is
passed to and from the server in a hidden form field.

Since the view state data resides in a hidden form field (__VIEWSTATE); ViewState increases the size of
page and results in slow loading of page at browser. You should be aware of when ViewState is helping you
and when it is not.

For example, if you are binding a control to data on every round trip , then you do not need the control to
maintain it's view state, since you will wipe out any re-populated data in any case. ViewState is enabled for
all server controls by default. To disable it, set the EnableViewState property of the control to false, as in
the following example:
< asp:datagrid EnableViewState="false" datasource="..." runat="server"/>
You can also turn ViewState off at the page level. This is useful when you do not post back from a page at
all, as in the following example:
< %@ Page EnableViewState="false" %>
Note that this attribute is also supported by the User Control directive.

29. Explain the concept of Web Application.


An introduction to web applications
A web application consists of a set of web pages that are generated in response to user requests. The Internet
has many different types of web applications, such as search engines, online stores, auctions, news sites,
discussion groups, games, and so on.
Properties of web applications
• Web applications are a type of client/server application. In that type of application, a user at a client
computer accesses an application at a server computer. In a web application, the client and server
computers are connected via the Internet or via an intranet (a local area network).
• In a web application, the user works with a web browser at the client computer. The web browser
provides the user interface for the application. The most popular web browsers are Microsofts
Internet Explorer, .Mozilla Firefox
• The application runs on the server computer under the control of web server software. For ASP.NET
web applications, the server must run Microsofts web server, called Internet Information Services, or
IIS.
• For most web applications, the server computer also runs a database management system, or DBMS,
such as Microsofts SQL Server. The DBMS provides access to information stored in a database. To
improve performance on larger applications, the DBMS can be run on a separate server computer.
• The user interface for a web application is implemented as a series of web pages that are displayed in
the web browser. Each web page is defined by a web form using HTML, or Hypertext Markup
Language, which is a standardized set of markup tags.
• The web browser and web server exchange information using HTTP (Hypertext Transfer Protocol).
30. What is difference between Response.Redirect and Server.Transfer?
Response.Redirect vs Server.Transfer
Server.Transfer or Response.Redirect both are the method of choice for transferring the user from one place
in the application to another
Server.Transfer is similar in that it sends the user to another page with a statement such as
Server.Transfer("WebForm2.aspx"). However, the statement has a number of distinct advantages and
disadvantages.
Firstly, transferring to another page using Server.Transfer conserves server resources. Instead of telling the
browser to redirect, it simply changes the "focus" on the Web server and transfers the request. This means
you don't get quite as many HTTP requests coming through, which therefore eases the pressure on your Web
server and makes your applications run faster.
But watch out: because the "transfer" process can work on only those sites running on the server, you can't
use Server.Transfer to send the user to an external site. Only Response.Redirect can do that.
The other side debates that Server.Transfer is not user friendly because the page requested may not be the
page that shows in the URL. Response.Redirect is more user-friendly, as the site visitor can bookmark
the page that they are redirected to.
Secondly, Server.Transfer maintains the original URL in the browser. This can really help streamline data
entry techniques, although it may make for confusion when debugging.
That's not all: The Server.Transfer method also has a second parameter"preserveForm". If you set this to
True, using a statement such as Server.Transfer("WebForm2.aspx", True), the existing query string and
any form variables will still be available to the page you are transferring to.
For example, if your WebForm1.aspx has a TextBox control called TextBox1 and you transferred to
WebForm2.aspx with the preserveForm parameter set to True, you'd be able to retrieve the value of the
original page TextBox control by referencing Request.Form("TextBox1").

31. What is a bubbled event in ASP.NET server side controls?


Bubbling an Event
The ASP.NET page framework provides a technique called event bubbling that allows a child control to
propagate events up its containment hierarchy. Event bubbling enables events to be raised from a more
convenient location in the controls hierarchy and allows event handlers to be attached to the original control
as well as to the control that exposes the bubbled event.
Event bubbling is used by the data-bound controls (Repeater, DataList, and DataGrid) to expose command
events raised by child controls (within item templates) as top-level events. While ASP.NET server controls
in the .NET Framework use event bubbling for command events (events whose event data class derives from
CommandEventArgs), any event defined on a server control can be bubbled.

32. What is smart navigation in ASP.NET Pages?


When a page is requested by an Internet Explorer 5 browser, or later, smart navigation enhances the user's
experience of the page by performing the following:
• Eliminating the flash caused by navigation.
• Persisting the scroll position when moving from page to page.
• Persisting element focus between navigations.
• Retaining only the last page state in the browser's history.
• Smart navigation is best used with ASP.NET pages that require frequent postbacks but with visual
content that does not change dramatically on return. Consider this carefully when deciding whether
to set this property to true.
Set the SmartNavigation attribute to true in the @ Page directive in the .aspx file. When the page is
requested, the dynamically generated class sets this property.

33. What method do you use to explicitly kill a users session in ASP.NET?
The Session.Abandon method destroys all the objects stored in a Session object and releases their
resources. If you do not call the Abandon method explicitly, the server destroys these objects when the
session times out.

34. What does the "EnableViewState" property do? Why would I want it on or off?
EnableViewState turns on the automatic state management feature that enables server controls to re-populate
their values on a round trip without requiring you to write any code. This feature is not free however, since
the state of a control is passed to and from the server in a hidden form field. You should be aware of when
ViewState is helping you and when it is not.
For example, if you are binding a control to data on every round, then you do not need the control to
maintain its view state, since you will wipe out any re-populated data in any case. ViewState is enabled for
all server controls by default. To disable it, set the EnableViewState property of the control to false.

35. What are the different modes for the sessionstates in the web.config file?
Off: Indicates that session state is not enabled.
Inproc: Indicates that session state is stored locally.
StateServer: Indicates that session state is stored on a remote server.
SQLServer: Indicates that session state is stored on the SQL Server.

36. Which two properties are on every validation control?


All of the validation controls inherit from the base class BaseValidator so they all have a series of properties
and methods that are common to all validation controls. They are:
ControlToValidate - This value is which control the validator is applied to.
ErrorMessage - This is the error message that will be displayed in the validation summary.
IsValid - Boolean value for whether or not the control is valid.
Validate - Method to validate the input control and update the IsValid property.
Display - This controls how the error message is shown.
Here are the possible options:
• None (The validation message is never displayed.)
• Static (Space for the validation message is allocated in the page layout.)
• Dynamic (Space for the validation message is dynamically added to the page if validation fails.)

37. What is ASP.NET?


ASP.NET is a technology for creating dynamic Web applications. It is part of the .NET Framework; you can
write ASP.NET applications in most .NET compatible languages, including Visual Basic, C#, J# and
JScript. ASP.NET pages (Web Forms) are compiled, providing better performance than with scripting
languages.
Web Forms allow you to build powerful forms-based Web pages. When building these pages, you can use
ASP.NET server controls to create common UI elements, and program them for common tasks. These
controls allow you to rapidly build a Web Form out of reusable built-in or custom components, simplifying
the code of a page.
ASP.NET provides a programming model, and infrastructure, to make creating scalable, secure and stable
applications faster, and easier than with previous Web technologies

38. What are main parts of ASP.NET?


• A page and controls framework (Web Forms)
• The ASP.NET compiler
• Security infrastructure
• State-management facilities
• Application configuration
• Health monitoring and performance features
• Debugging support
• An XML Web services framework
• Extensible hosting environment and application life cycle management
• An extensible designer environment

39. What is the difference between code inline and code behind models in Asp.Net?
Code-Inline model in Asp.Net
In Code-Inline model the code & event handlers for the controls are located in <script> blocks in the same
.aspx file that contains the HTML and controls. Code-Inline model is useful when you want to maintain your
code and presentation logic in a single file.
Code-behind model in Asp.Net
ASP.NET also supports another way to factor your code and presentation content, called the code-behind
model. When using code-behind, the code for handling events is located in a physically separate file from
the page that contains server controls and markup. This clear delineation between code and content is useful
when you need to maintain these separately, such as when more than one person is involved in creating the
application. It is often common in group projects to have designers working on the UI portions of an
application while developers work on the behavior or code. The code-behind model is well-suited to that
environment.

40. What are the ways to manage state in Asp.Net application?


Ways to manage state in Asp.Net are:
• Using Session and Application objects to cache information.
• Using Memory and Disk Cookies to preserve information.
• Using hidden input fields or the URL -embedded information to pass information from one page to
another.
• Using the ViewState property of the page to set and retrieve information stored in a StateBag object.
• Using SQL Server to store state information.

41. Explain the limitation & issues with the Cookies?


Limitation & Issues with Cookies
Using cookies gives you excellent state management capabilities, as they are simple to implement, and they
help you move resources off the server. Like almost any particular technique, cookies have some limitations.

Some Users Dont Allow Cookies


Some users believe that viruses can be sent in a cookie and will not allow them onto their computers.
Although there have never been any documented cases of this happening, and no one could realistically send
a virus through a cookie, a lot of users still turn off the ability to accept cookies. When this happens, the user
will not be able to use your site if you use cookies for managing state.
Performance Can Deteriorate
Imagine that a user walks through a wizard on your site, as you gather 100 pieces of data from that user over
several pages. Each page needs to post gathered data to the server. If you wait until all 100 pieces of data are
gathered, you need to store that data somewhere in the meantime. If you keep putting data into a cookie,
there is a lot of data being sent back and forth between the browser and the server. This will eat up a lot of
bandwidth and could slow your whole site down. Remember, the data has to go both ways for each page the
users hit on your site.
Cookies Take Up Memory
Some browsers impose a limit on the size of the cookie data they can accept, or the number of cookies they
can accept at one time. In addition, the amount of memory that you may chew up on the users machine may
cause their operating system to swap some memory to disk. Under this circumstance, the cookie has slowed
down your users machine as well as the server.

42. Explain the Limitations & Issues with Automatic SQL Server State Management?
• Although using SQL Server to store your session state relieves you of many difficult development
issues, you’ll still need to consider some important limitations:
• You’re limited to SQL Server.
• This technique can only use SQL Server, no other server database. If you do not have a SQL Server
installation available, you will be unable to use this solution.
• Performance may suffer.
• Like any of the state management techniques, using SQL Server to manage your applications state
can cause your performance degrade a little. Because it takes a little bit of time to make a connection
and read and write state information in the database, theres no avoiding a small bit of overhead.

43. What is the purpose of Server.MapPath method in Asp.Net?


In Asp.Net Server.MapPath method maps the specified relative or virtual path to the corresponding physical
path on the server. Server.MapPath takes a path as a parameter and returns the physical location on the hard
drive.
Syntax
Suppose your Text files are located at D:\project\MyProject\Files\TextFiles

If the root project directory is MyProject and the aspx file is located at root then to get the same path use
code
/* physical path of TextFiles */
string TextFilePath=Server.MapPath("Files/TextFiles");

44. Introduction to Web Service Methods in ASP.NET.


Methods of a class that implement a Web service do not automatically have the ability to receive Web
service requests and send back responses, but with Web services created using ASP.NET, it is very simple to
add that capability. Apply a WebMethod attribute to public methods. Methods of a Web service class that
can be communicated with over the Web are called Web service methods.
Web service methods are a key part of the messaging infrastructure employed by Web services. That is, a
client and a Web service communicate using messages, specifically SOAP messages, by default. Clients
send a SOAP request to a Web service and a Web service method typically returns a SOAP response. Web
services define the type of messages they accept using operations, as defined by Web Services Description
Language (WSDL). These operations correlate to each of the Web service methods within a Web service.
Even though each of these Web service methods are defined in ASP.NET using a method of a class, it is
important to realize that the data that is eventually communicated over the network must be serialized into
XML. As such, it is important to remember that Web services are not a replacement for DCOM, but rather a
messaging infrastructure for communicating across platforms using industry standards.

45. Explain WebMethod Attribute in Asp.Net Web Service.


Attaching the WebMethod attribute to a Public method indicates that you want the method exposed as part
of the XML Web service. The WebMethod attribute tells .NET that a particular public method should be
exposed as a web-callable method. The WebMethod attribute has six associated properties to document and
change the behavior of your web method. They are:
Description
MessageName
EnableSession
CacheDuration
TransactionOption
BufferResponse

The first two properties are used to document a web method, while the others affect its behavior.

46. What are the web services in ASP.NET?


Introduction to web service
A Web service is a class that allows its methods to be called by methods on other machines via common
data formats and protocols, such as XML and HTTP. In .NET, the over-the-network method calls are
commonly implemented through the Simple Object Access Protocol (SOAP), an XML-based protocol
describing how to mark up requests and responses so that they can be transferred via protocols such as
HTTP. Using SOAP, applications represent and transmit data in a standardized XML-based format.
A Web service is a software component stored on one machine that can be accessed by an application (or
other software component) on another machine over a network. The machine on which the Web service
resides is referred to as a remote machine. The application (i.e., the client) that accesses the Web service
sends a method call over a network to the remote machine, which processes the call and returns a response
over the network to the application.
Methods in a Web service are invoked through a Remote Procedure Call (RPC). These methods, which are
marked with the WebMethod attribute, are often referred to as Web service methods or simply Web
methods. Declaring a method with attribute WebMethod makes the method accessible to other classes
through RPCs and is known as exposing a Web method.
Web services have important implications for business-to-business (B2B) transactions. They enable
businesses to conduct transactions via standardized, widely available Web services rather than relying on
proprietary applications. Web services and SOAP are platform and language independent, so companies can
collaborate via Web services without worrying about the compatibility of their hardware, software and
communications technologies.
Web services are not the best solution for certain performance-intensive applications, because applications
that invoke Web services experience network delays. Also, data transfers are typically larger because data is
transmitted in text-based XML formats.
47. What is the use of SOAP (Simple Object Access Protocol) in .Net Web Services?
The Simple Object Access Protocol (SOAP) is a platform-independent protocol that uses XML to make
remote procedure calls.
Each request and response is packaged in a SOAP message containing the information that a Web service
requires to process the message.
SOAP supports an extensive set of types like the primitive types, DataSet, DateTime, XmlNode and others.
SOAP can also transmit arrays of these types and objects of user-defined types.
When a program invokes a Web method, the request and all relevant information are packaged in a SOAP
message and sent to the server on which the Web service resides.
A Web service receives a SOAP message and parses its contents (contained in a SOAP envelope) to
determine the method that the client wishes to execute and the method's arguments.
After a Web service parses a SOAP message, the proper method is called and the response is sent back to
the client in another SOAP message. The client parses the response to retrieve the result.

48. Can you use User-Defined Types in Web Services?


It is possible to process user-defined types (also known as custom types) in a Web service. These types can
be passed to or returned from Web methods. Web service clients also can use these user-defined types,
because the proxy class created for the client contains these type definitions.
Custom types that are sent to or from a Web service are serialized, enabling them to be passed in XML
format. This process is referred to as XML serialization.
Classes that are used to specify Web method return types and parameter types must provide a public default
or parameterless constructor. Properties and instance variables that should be serialized in XML format must
be declared public. Properties that should be serialized must provide both get and set accessors. Read-only
properties are not serialized. Data that is not serialized simply receives its default value when an object of
the class is deserialized.

49. What is WSDL?


WSDL (Web Services Description Language) is an XML-based language for describing Web services and
how to access them. It is a document written in XML. The document describes a Web service. It specifies
the location of the service and the operations (or methods) the service exposes.
About WSDL (Web Services Description Language)
• WSDL stands for Web Services Description Language
• WSDL is written in XML
• WSDL is an XML document
• WSDL is used to describe Web services
• WSDL is also used to locate Web services
• WSDL is not yet a W3C standard
• It possible to group together the definitions of several web services in one single WSDL document.
According to W3C
As communications protocols and message formats are standardized in the web community, it becomes
increasingly possible and important to be able to describe the communications in some structured way.
WSDL addresses this need by defining an XML grammar for describing network services as collections of
communication endpoints capable of exchanging messages. WSDL service definitions provide
documentation for distributed systems and serve as a recipe for automating the details involved in
applications communication.

50. What are the major elements of WSDL Document?


Following are the major parts of WSDL document
WSDL Ports
The < portType > element is the most important WSDL element. It describes a web service, the operations
that can be performed, and the messages that are involved. The < portType > element can be compared to a
function library (or a module, or a class) in a traditional programming language.
WSDL Messages
The < message > element defines the data elements of an operation. Each message can consist of one or
more parts. The parts can be compared to the parameters of a function call in a traditional programming
language.
WSDL Types
The < types > element defines the data type that are used by the web service. For maximum platform
neutrality, WSDL uses XML Schema syntax to define data types.
WSDL Bindings
The < binding > element defines the message format and protocol details for each port.

51. What is UDDI?


The Universal Description, Discovery and Integration (UDDI) protocol is one of the major building blocks
required for successful Web services. UDDI creates a standard interoperable platform that enables
companies and applications to quickly, easily, and dynamically find and use Web services over the Internet.
UDDI is a cross-industry effort driven by major platform and software providers, as well as marketplace
operators and e-business leaders. To find web services you can visit http://www.uddi.org.
UDDI is an important enabling element of the service-oriented approach to software design. The standard
specifies protocols for accessing a registry for Web services, methods for controlling access to the registry,
and a mechanism for distributing or delegating records to other registries. In short, a UDDI registry provides
a standards based approach to locate a software service, to invoke that service, and to manage metadata
about that service.
The UDDI project takes advantage of Worldwide Web Consortium (W3C) and Internet Engineering Task
Force (IETF) standards such as Extensible Markup Language (XML), and HTTP and Domain Name System
(DNS) protocols. Additionally, cross platform programming features are addressed by adopting early
versions of the proposed Simple Object Access Protocol (SOAP) known as XML Protocol messaging
specifications found at the W3C Web site. The UDDI protocol is the building block that will enable
businesses to quickly, easily and dynamically find and transact with one another using their preferred
applications.

52. How do people use UDDI?


A business may deploy one or more private and/or public UDDI registries. A private registry permits access
to only authorized users. A public registry does not restrict access to the registry. A business may choose to
deploy multiple registries in order to segregate internal and external service information. An internal registry
supports intranet applications, while an external registry supports extranet applications. Industry groups may
deploy a UDDI registry to support public or private exchanges.

53. What is the UDDI Business Registry (UBR)?


The UDDI Business Registry (UBR) is a free, public UDDI registry currently jointly operated by IBM,
Microsoft, NTT Communications, and SAP. Anyone is free to publish information to any of the UBR
nodes and to query any of these.
In short, a UDDI registry provides a standards based approach to locate a software service, to invoke that
service, and to manage metadata about that service.

54. What is ADO.NET?


ADO.NET is a set of classes that expose data access services to the .NET Applications. ADO ( or ActiveX
Data Objects ) is an easy-to-use yet extensible technology for adding database connectivity to Web pages.
ADO.NET is the next generation of ADO, providing the interface for accessing, manipulating, and
exchanging data in the Microsoft .NET Framework.
The ADO.NET components have been designed to factor data access from data manipulation. There are two
central components of ADO.NET that accomplish this: the DataSet, and the .NET Framework data provider,
which is a set of components including the Connection, Command, DataReader, and DataAdapter objects.

55. What are the main classes/Components of ADO.NET?


ADO.NET is comprised of many classes, but five take center stage:
Connection :Represents a connection to a data source.
Command :Represents a query or a command that is to be executed by a data source.
DataSet :Represents data. The DataSet can be filled either from a data source (using a DataAdapter object)
or dynamically.
DataAdapter :Used for filling a DataSet from a data source.
DataReader :Used for fast, efficient, forward-only reading of a data source.
56. Explain How ADO.NET Works?
ADO.NET uses two types of objects to access the data in a database: datasets, which can contain one or
more data tables, and .NET data provider objects, which include data adapters, commands, and connections.
A dataset stores data from the database so that it can be accessed by the application. The .NET data provider
objects retrieve data from and update data in the database.
To retrieve data from a database and store it in a data table, a data adapter object issues a Select statement
thats stored in a command object. Next, the command object uses a connection object to connect to the
database and retrieve the data. Then, the data is passed back to the data adapter, which stores the data in the
dataset.
To update the data in a database based on the data in a data table, the data adapter object issues an Insert,
Update, or Delete statement thats stored in a command object. Then, the command object uses a connection
to connect to the database and update the data.
The data provider remains connected to the database only long enough to retrieve or update the specified
data. Then, it disconnects from the database and the application works with the data via the dataset object.
This is referred to as a disconnected data architecture.
All of the ADO.NET objects are implemented by classes in the System.Data namespace of the .NET
Framework. However, the specific classes used to implement the connection, command, and data adapter
objects depend on the .NET data provider you use.

57. What is DataSet?


A DataSet is a cache of records retrieved from a data source. It works like a virtual data store: A dataset
includes one or more tables based on the tables in the actual database, and it can include information about
the relationships between those tables and constraints on what data the tables can contain.
The DataSet is a memory-resident representation of data that provides a consistent relational programming
model regardless of the data source. The DataSet represents a complete set of data, including related tables,
constraints, and relationships among the tables.
The DataSet object is central to supporting disconnected, distributed data scenarios with ADO.NET. The
DataSet class is explicitly designed for data access independent of any data source. As a result it can be used
with multiple and differing data sources, used with XML data, or used to manage data local to the
application. The DataSet contains a collection of one or more DataTable objects made up of rows and
columns of data, as well as primary key, foreign key, constraint, and relation information about the data in
the DataTable objects.

58. What are the fundamental parts of DataSet?


The fundamental parts of a dataset are exposed to you through standard programming constructs such as
properties and collections. For example:
The DataSet class includes the Tables collection of data tables and the Relations collection of DataRelation
objects.
The DataTable class includes the Rows collection of table rows, the Columns collection of data columns,
and the ChildRelations and ParentRelations collections of data relations.
The DataRow class includes the RowState property, whose values indicate whether and how the row has
been changed since the data table was first loaded from the database. Possible values for the RowState
property include Deleted, Modified, New, and Unchanged.

59. What is the use of DataAdapter Class?


DataAdapter Class represents a set of SQL commands and a database connection that are used to fill the
DataSet and update the data source.The DataAdapter serves as a bridge between a DataSet and a data source
for retrieving and saving data.

Adapters are used to exchange data between a data source and a dataset. In many applications, this means
reading data from a database into a dataset, and then writing changed data from the dataset back to the
database. You can use a data adapter to perform the following operations:
• Retrieve rows from a data store into corresponding data tables within the dataset.
• To retrieve rows into a dataset, use the Fill method on a data adapter object (SqlDataAdapter,
OleDbDataAdapter, OdbcDataAdapter, or OracleDataAdapter). When you invoke the Fill method, it
transmits an SQL SELECT statement to the data store.
• Transmit changes made to a dataset table to the corresponding data store.
• To transmit a dataset table of the dataset to the data store, use the adapter's Update method. When
you invoke the method, it executes whatever SQL INSERT, UPDATE or DELETE statements are
needed, depending on whether the affected record is new, changed, or deleted.

60. Which DataAdapters are available for use with different Databases in ADO.NET?
ADO.NET makes these data adapters available for use with databases:
• The OleDbDataAdapter object is suitable for use with any data source exposed by an OLE DB
provider.
• The SqlDataAdapter object is specific to SQL Server. Because it does not have to go through an
OLE DB layer, it is faster than the OleDbDataAdapter. However, it can only be used with SQL
Server 7.0 or later.
• The OdbcDataAdapter object is optimized for accessing ODBC data sources.
• The OracleDataAdapter object is optimized for accessing Oracle databases.

61. How can you update Database using DataAdapter and the DataSet?
Updating the Database with a DataAdapter and the DataSet
The Update method of the DataAdapter is called to resolve changes from a DataSet back to the data source.
The Update method, like the Fill method, takes as arguments an instance of a DataSet, and an optional
DataTable object or DataTable name. The DataSet instance is the DataSet that contains the changes that
have been made, and the DataTable identifies the table from which to retrieve the changes.
When you call the Update method, the DataAdapter analyzes the changes that have been made and executes
the appropriate command (INSERT, UPDATE, or DELETE). When the DataAdapter encounters a change to
a DataRow, it uses the InsertCommand, UpdateCommand, or DeleteCommand to process the change.
The Update method will resolve your changes back to the data source, however other clients may have
modified data at the data source since the last time you filled the DataSet. To refresh your DataSet with
current data, use the DataAdapter and Fill the DataSet again. New rows will be added to the table, and
updated information will be incorporated into existing rows. The Fill method determines whether a new row
will be added or an existing row will be updated by examining the primary key values of the rows in the
DataSet and the rows returned by the SelectCommand. If the Fill method encounters a primary key value for
a row in the DataSet that matches a primary key value from a row in the results returned by the
SelectCommand, it updates the existing row with the information from the row returned by the
SelectCommand and sets the RowState of the existing row to Unchanged. If a row returned by the
SelectCommand has a primary key value that does not match any of the primary key values of the rows in
the DataSet, the Fill method adds a new row with a RowState of Unchanged.

62. Explain the Use of connection pooling in ADO.NET


Connection pooling enables an application to use a connection from a pool of connections that do not need
to be re-established for each use. Once a connection has been created and placed in a connection pool, an
application can reuse that connection without performing the complete connection creation process.
By default, the connection pool is created when the first connection with a unique connection string
connects to the database. The pool is populated with connections up to the minimum pool size. Additional
connections can be added until the pool reaches the maximum pool size.
When a user request a connection, it is returned from the pool rather than establishing new connection and,
when a user releases a connection, it is returned to the pool rather than being released. But be sure than your
connections use the same connection string each time. Here is the Syntax
conn.ConnectionString = "integrated Security=SSPI; SERVER=192.168.0.123; DATABASE=MY_DB;
Min Pool Size=4;Max Pool Size=40;Connect Timeout=14;";

63. How can you search the Data in DataSet?


Searching for Data in the DataSet
When querying a DataSet for rows that match particular criteria, you can increase the performance of your
searches by taking advantage of index-based lookups. When you assign a PrimaryKey value to a DataTable,
an index is created. When you create a DataView for a DataTable, an index is also created. Here are a few
tips for taking advantage of index-based lookups.
If the query is against the columns that make up the PrimaryKey of the DataTable, use
DataTable.Rows.Find instead of DataTable.Select. For queries involving non-primary key columns, you can
improve performance for multiple queries of the data using a DataView. When you apply a sort order to a
DataView, an index is built that is used when searching. The DataView exposes the Find and FindRows
methods to query the data in the underlying DataTable. If you do not require a sorted view of a table, you
can still take advantage of index-based lookups by creating a DataView for the DataTable. Note that this is
only an advantage if you are performing multiple queries on the data. If you are only performing a single
query, the processing required to create the index reduces the performance gained by using the index.

64. How to set the Focus on control in ASP.NET?


In earlier versions of ASP.NET, assigning focus to a control involves writing client-side script (such as
JavaScript). In ASP.NET 2.0, this process has been much simplified, and you can now set the focus of a
control via its Focus() method. Like

txtName.Focus();

You can also set the focus of a control through the SetFocus( ) method of the Page class. The syntax is:

Page.SetFocus(controlName);

Apart from this you can use defaultfocus attribute to set the control that will be assigned the focus when
the form is loaded.
< form id="form1" runat="server"
defaultfocus="txtEmail"
>

65. How to set default button on a Web Form?


Setting a default button on a Web Form in ASP.NET 2.0
In ASP.NET 2.0, you can now set a default button on a page so that when the user presses the Enter key the
button is automatically invoked.

For example, you have a page with two TextBox controls and two Button controls. You can configure the
Submit button to be the default button so it is automatically clicked when a user presses the Enter key. To
set the default button of form use
< form id="form1" runat="server"
defaultbutton="btnSubmit">

66. What is Partial Classes in Asp.Net 2.0?


Partial Classes Concept in Asp.Net 2.0
One of the language enhancements in .NET 2.0 - available to both VB2005 and C# 2.0 programmersis
support for partial classes. In a nutshell, partial classes mean that your class definition can be split into
multiple physical files. Logically, partial classes do not make any difference to the compiler. During compile
time, it simply groups all the various partial classes and treats them as a single entity.
Benefits of Partial Classes
One of the greatest benefits of partial classes is that they allow a clean separation of business logic and the
user interface (in particular, the code that is generated by the Visual Studio Designer). Using partial
classes, the UI code can be hidden from the developer, who usually has no need to access it anyway.
Partial classes also make debugging easier, as the code is partitioned into separate files. This feature
also helps members of large development teams work on their pieces of a project in separate physical
files.

67. What are the new features in ASP.NET 2.0?


ASP.NET is a programming framework built on the common language runtime that can be used on a server
to build powerful Web applications. The first version of ASP.NET offered several important advantages
over previous Web development models. ASP.NET 2.0 improves upon that foundation by adding support
for several new and exciting features in the areas of developer productivity, administration and management,
extensibility, and performance
New Server Controls:
ASP.NET 2.0 introduces many new server controls that enable powerful declarative support for data access,
login security, wizard navigation, menus, treeviews, portals, and more. Many of these controls take
advantage of core application services in ASP.NET for scenarios like data access, membership and roles,
and personalization.
Master Pages:
This feature provides the ability to define common structure and interface elements for your site, such as a
page header, footer, or navigation bar, in a common location called a "master page", to be shared by many
pages in your site. In one simple place you can control the look, feel, and much of functionality for an entire
Web site. This improves the maintainability of your site and avoids unnecessary duplication of code for
shared site structure or behavior.

Themes and Skins:


The themes and skins features in ASP.NET 2.0 allow for easy customization of your site's look-and-feel.
You can define style information in a common location called a "theme", and apply that style information
globally to pages or controls in your site. Like Master Pages, this improves the maintainability of your site
and avoid unnecessary duplication of code for shared styles.
Personalization:
Using the new personalization services in ASP.NET 2.0 you can easily create customized experiences within
Web applications. The Profile object enables developers to easily build strongly-typed, sticky data stores for
user accounts and build highly customized, relationship based experiences. At the same time, a developer
can leverage Web Parts and the personalization service to enable Web site visitors to completely control the
layout and behavior of the site, with the knowledge that the site is completely customized for them.
Personalization scenarios are now easier to build than ever before and require significantly less code and
effort to implement.
Localization:
Enabling globalization and localization in Web sites today is difficult, requiring large amounts of custom
code and resources. ASP.NET 2.0 and Visual Studio 2005 provide tools and infrastructure to easily build
Localizable sites including the ability to auto-detect incoming locale's and display the appropriate locale
based UI. Visual Studio 2005 includes built-in tools to dynamically generate resource files and localization
references. Together, building localized applications becomes a simple and integrated part of the
development experience.
Administration and Management:
New tools like Configuration API, ASP.NET MMC Admin Tool, Pre-compilation Tool, Health Monitoring
and Tracing have been introduced.
Performance and Scalability:
ASP.NET is built to perform, using a compiled execution model for handling page requests and running on
the world's fastest web server, Internet Information Services. ASP.NET 2.0 also introduces key performance
benefits over previous versions like 64-Bit Support and Caching Improvements.

68. What is the use of Tree View Control in ASP.NET 2.0?


New site navigation controls in ASP.NET 2.0
Microsoft ASP.NET 2.0 introduces two new site navigation controls, the TreeView and Menucontrols,
which can be used to represent hierarchical data. Both controls are feature rich and were designed to work in
a wide-variety of scenarios. Both controls can be used to display static data, site-map data, and even
database data. In addition, both controls support a rich client-side experience. The TreeView and Menu
controls render JavaScript for uplevel browsers, but they are also compatible with downlevel browsers.
Use of TreeView control
You can use the TreeView control in any situation in which you need to display hierarchical data. For
example, you can use this control when displaying a navigation menu, displaying database records from
database tables in a Master/Detail relation, displaying the contents of an XML document, or displaying files
and folders from the file system.

69. What is the use of Master Pages in ASP.NET 2.0?


ASP.NET master pages allow you to create a consistent layout for the pages in your application. A single
master page defines the look and feel and standard behavior that you want for all of the pages (or a group of
pages) in your application. You can then create individual content pages that contain the content you want to
display. When users request the content pages, they merge with the master page to produce output that
combines the layout of the master page with the content from the content page.
The ContentPlaceHolder control is where the page specific content will be placed. This master page is a
template that will act as the base for all subsequent pages.
A master page is an ASP.NET file with the extension .master (for example, MySite.master) with a
predefined layout that can include static text, HTML elements and server controls.
The master page is identified by a special @ Master directive that replaces the @ Page directive that is used
for ordinary .aspx pages. The @ Master directive can contain most of the same directives that a @ Control
directive can contain. For example, the following master-page directive includes the name of a code-behind
file, and assigns a class name to the master page.
You define the content for the master page's placeholder controls by creating individual content pages,
which are ASP.NET pages (.aspx files and, optionally, codebehind files) that are bound to a specific master
page. The binding is established in the content page's @ Page directive by including a MasterPageFile
attribute that points to the master page to be used.

70. What is polymorphism in Object Oriented Programming (OOPS) Languages?


In object-oriented programming, polymorphism is a generic term that means 'many shapes'. (from the
Greek meaning "having multiple forms"). Polymorphism is briefly described as "one interface, many
implementations." polymorphism is a characteristic of being able to assign a different meaning or usage to
something in different contexts - specifically, to allow an entity such as a variable, a function, or an object to
have more than one form.
There are two types of polymorphism one is compile time polymorphism and the other is run time
polymorphism. Compile time polymorphism is functions and operators overloading. Runtime time
polymorphism is done using inheritance and virtual functions. Here are some ways how we implement
polymorphism in Object Oriented programming languages
Interface and abstract methods
Like in C# or JAVA different classes implement a common interface in different ways; is an example of
Runtime polymorphism. The interface defines the abstract member functions (no implementation). In class
that implement the interface; we define body of those abstract members according to the requirement. Means
single definition in interface but multiple implementation in child classes.
Virtual member functions
Using virtual member functions in an inheritance hierarchy allows run-time selection of the appropriate
member function. A virtual function is a member function of the base class and which is redefined by the
derived class. Such functions can have different implementations that are invoked by a run-time
determination of the subtype (virtual method invocation, dynamic binding).
Function Overloading
Polymorphism means that functions assume different forms at different times. In case of compile time it is
called function overloading.Two or more functions can have same name but their parameter list should be
different either in terms of parameters or their data types. The functions which differ only in their return
types cannot be overloaded. The compiler will select the right function depending on the type of parameters
passed.
Operator Overloading
In polymorphism operators can also be overloaded (Compile time polymorphism). Operators can be
overloaded in order to perform special functions with respect to the class. With the help of operator
overloading standard operations such as + , - , * , etc can be applied on the objects of the class.

71. What is a Virtual Functions in class?


A virtual function is a member function of the base class and which is redefined by the derived class. When
a derived class inherits the class containing the virtual function, it has ability to redefine the virtual
functions.
A virtual function has a different functionality in the derived class according to the requirement. The virtual
function within the base class provides the form of the interface to the function. Virtual function implements
the philosophy of one interface and multiple methods (polymorphism).
The virtual functions are resolved at the run time. This is called dynamic binding. The functions which are
not virtual are resolved at compile time which is called static binding. A virtual function is created using
the keyword virtual which precedes the name of the function.

72. What is Encapsulation in Object Oriented Programming (OOPS) Languages?


Encapsulation is the procedure of covering up of data and functions into a single unit. Encapsulation (also
information hiding) consists of separating the external aspects of an object which are accessible to other
objects, from the internal implementation details of the object, which are hidden from other objects.
A process, encapsulation means the act of enclosing one or more items within a (physical or logical)
container (Class).
Object-oriented programming is based on encapsulation. When an objects state and behavior are kept
together, they are encapsulated. That is, the data that represents the state of the object and the methods
(Functions and Subs) that manipulate that data are stored together as a cohesive unit.
The object takes requests from other client objects, but does not expose its the details of its data or code to
them. The object alone is responsible for its own state, exposing public messages for clients, and declaring
private methods that make up its implementation. The client depends on the (hopefully) simple public
interface, and does not know about or depend on the details of the implementation.
For example, a HashTable object will take get() and set() requests from other objects, but does not expose its
internal hash table data structures or the code strategies that it uses.

73. Explain the advantages of Encapsulation in Object Oriented Programming Languages.


Benefits of Encapsulation in oops:
Encapsulation makes it possible to separate an objects implementation from its behavior to restrict access to
its internal data. This restriction allows certain details of an objects behavior to be hidden. It allows us to
create a "black box" and protects an objects internal state from corruption by its clients.
Encapsulation is a technique for minimizing interdependencies among modules by defining a strict external
interface. This way, internal coding can be changed without affecting the interface, so long as the new
implementation supports the same (or upwards compatible) external interface. So encapsulation prevents a
program from becoming so interdependent that a small change has massive ripple effects.
The implementation of an object can be changed without affecting the application that uses it for: Improving
performance, fix a bug, consolidate code or for porting.

74. Limitations and Restrictions of Interface


The essential idea to remember is that an interface never contains any implementation. The following
restrictions and imitations are natural consequences of this:
You're not allowed any fields in an interface, not even static ones. A field is an implementation of an object
attribute.
You're not allowed any constructors in an interface. A constructor contains the statements used to initialize
the fields in an object, and an interface does not contain any fields!
You're not allowed a destructor in an interface. A destructor contains the statements used to destroy an
object instance.
You cannot supply an access modifier. All methods in an interface are implicitly public.
You cannot nest any types (enums, structs, classes, interfaces, or delegates) inside an interface.
You're not allowed to inherit an interface from a struct or a class. Structs and classes contain
implementation; if an interface were allowed to inherit from either, it would be inheriting some
implementation.

75. What is an Object?


An object is an instance of a class. It can be uniquely identified by its name and it defines a state which is
represented by the values of its attributes at a particular time.
An object can be considered a "thing" that can perform a set of activities. The set of activities that the object
performs defines the object's behavior.
The state of the object changes according to the methods which are applied to it. We refer to these possible
sequences of state changes as the behavior of the object. So the behavior of an object is defined by the set of
methods which can be applied on it.
Objects can communicate by passing messages to each other.

76. What is inheritance?


Inheritance is the mechanism which allows a class A to inherit properties of a class B. We say "A inherits
from B''. Objects of class A thus have access to attributes and methods of class B without the need to
redefine them.
If class A inherits from class B, then B is called superclass of A. A is called subclass of B. Objects of a
subclass can be used where objects of the corresponding superclass are expected. This is due to the fact that
objects of the subclass share the same behavior as objects of the superclass.
However, subclasses are not limited to the state and behaviors provided to them by their superclass.
Subclasses can add variables and methods to the ones they inherit from the superclass.
In the literature you may also find other terms for "superclass" and "subclass". Superclasses are also called
parent classes or base classes. Subclasses may also be called child classes or just derived classes.
Inheritance Example
Like a car, truck or motorcycles have certain common characteristics- they all have wheels, engines and
brakes. Hence they all could be represented by a common class Vehicle which encompasses all those
attributes and methods that are common to all types of vehicles.
However they each have their own unique attributes; car has 4 wheels and is smaller is size to a truck;
whereas a motorcycle has 2 wheels. Thus we see a parent-child type of relationship here where the Car,
Truck or Motorcycle can inherit certain Characteristics from the parent Vehicle; at the same time having
their own unique attributes. This forms the basis of inheritance; Vehicle is the Parent, Super or the Base
class. Car, Truck and Motorcycle become the Child, Sub or the Derived class.

77. Explain some characteristics of inheritance.


A class inherits the members of its direct base class. Inheritance means that a class implicitly contains all
members of its direct base class, except for the constructors and destructors of the base class.
Some important aspects of inheritance are:
Inheritance is transitive. If C is derived from B, and B is derived from A, then C inherits the members
declared in B as well as the members declared in A.
A derived class extends its direct base class. A derived class can add new members to those it inherits, but it
cannot remove the definition of an inherited member.
Constructors and destructors are not inherited, but all other members are, regardless of their declared
accessibility. However, depending on their declared accessibility, inherited members might not be accessible
in a derived class.
A derived class can hide inherited members by declaring new members with the same name or signature.
Note however that hiding an inherited member does not remove that member; it merely makes that member
inaccessible in the derived class.
An instance of a class contains a set of all instance fields declared in the class and its base classes, and an
implicit conversion exists from a derived class type to any of its base class types. Thus, a reference to an
instance of some derived class can be treated as a reference to an instance of any of its base classes.
A class can declare virtual methods, properties, and indexers, and derived classes can override the
implementation of these function members. This enables classes to exhibit polymorphic behavior wherein
the actions performed by a function member invocation varies depending on the run-time type of the
instance through which that function member is invoked.

78. What is an Interface in Microsoft.Net?


An Interface is a reference type and it contains only abstract members. Interface's members can be Events,
Methods, Properties and Indexers. But the interface contains only declaration for its members. Any
implementation must be placed in class that realizes them. The interface can't contain constants, data fields,
constructors, destructors and static members. All the member declarations inside interface are implicitly
public.
Implementing an interface allows a class to become more formal about the behavior it promises to provide.
Interfaces form a contract between the class and the outside world, and this contract is enforced at build time
by the compiler. If your class claims to implement an interface, all methods defined by that interface must
appear in its source code before the class will successfully compile.

79. What is the difference between abstract class and interface?


We use abstract class and interface where two or more entities do same type of work but in different ways.
Means the way of functioning is not clear while defining abstract class or interface. When functionality of
each task is not clear then we define interface. If functionality of some task is clear to us but there exist some
functions whose functionality differs object by object then we declare abstract class.
We can not make instance of Abstract Class as well as Interface. They only allow other classes to inherit
from them. And abstract functions must be overridden by the implemented classes. Here are some
differences in abstract class and interface.
An interface cannot provide code of any method or property, just the signature. We dont need to put abstract
and public keyword. All the methods and properties defined in Interface are by default public and abstract.
An abstract class can provide complete code of methods but there must exist a method or property without
body.
A class can implement several interfaces but can inherit only one abstract class. Means multiple inheritance
is possible in .Net through Interfaces.
80. What is a static class?
We can declare a static class. We use static class when there is no data or behavior in the class that depends
on object identity. A static class can have only static members. We can not create instances of a static class
using the new keyword. .NET Framework common language runtime (CLR) loads Static classes
automatically when the program or namespace containing the class is loaded.
Here are some more features of static class:
• Static classes only contain static members.
• Static classes can not be instantiated. They cannot contain Instance Constructors
• Static classes are sealed.

81. What is static member of class?


A static member belongs to the class rather than to the instances of the class. In C# data fields, member
functions, properties and events can be declared static. When any instances of the class are created, they
cannot be used to access the static member.
To access a static class member, use the name of the class instead of an instance variable
Static methods and Static properties can only access static fields and static events.
Like: int i = Car.GetWheels;
Here Car is class name and GetWheels is static property.
Static members are often used to represent data or calculations that do not change in response to object state.

82. What is a field?


A field is a variable that is associated with a class or struct, or an instance of a class or struct. A field
declared with the static modifier defines a static variable, and a field declared without this modifier defines
an instance variable. A static field is associated with a type, whereas an instance variable is associated with
an instance.

83. What is the difference between value parameter and reference parameter?
A value parameter is used for "in" parameter passing, in which the value of an argument is passed into a
method, and modifications of the parameter do not impact the original argument. A value parameter refers to
its own variable, one that is distinct from the corresponding argument. This variable is initialized by copying
the value of the corresponding argument.
A reference parameter is used for "by reference" parameter passing, in which the parameter acts as an alias
for a caller-provided argument. A reference parameter does not itself define a variable, but rather refers to
the variable of the corresponding argument. Modifications of a reference parameter impact the
corresponding argument.

84. What is the use of parameter array?


A parameter array enables a many-to-one relationship: many arguments can be represented by a single
parameter array. In other words, parameter arrays enable variable length argument lists.
A parameter array is declared with a params modifier in C#. There can be only one parameter array for a
given method, and it must always be the last parameter specified. The type of a parameter array is always a
single dimensional array type. A caller can either pass a single argument of this array type, or any number of
arguments of the element type of this array type.

85. What is the difference between reference parameter and output parameter?
Modifications of a reference parameter and output parameter impact the corresponding argument. So an
output parameter is similar to a reference parameter, except that the initial value of the caller-provided
argument is unimportant.
In C# a reference parameter is declared with a ref modifier but an output parameter is declared with an out
modifier.

86. What is a constant?


A constant is a class member that represents a constant value: a value that can be computed at compile-time.

Constants are permitted to depend on other constants within the same program as long as there are no
circular dependencies. The example
class Constants
{
public const int A = 1;
public const int B = A + 1;
}
shows a class named Constants that has two public constants

87. What is the method of class?


A method is a member that implements a computation or action that can be performed by an object or class.
Methods have a (possibly empty) list of formal parameters, a return value (or void), and are either static or
non- static. Static methods are accessed through the class. Non-static methods, which are also called instance
methods, are accessed through instances of the class.
Methods can be overloaded, which means that multiple methods may have the same name so long as they
have unique signatures. The signature of a method consists of the name of the method and the number,
modifiers, and types of its formal parameters. The signature of a method does not include the return type.

88. What is the property of class?


A property is a member that provides access to an attribute of an object or a class. Examples of properties
include the length of a string, the size of a font, the caption of a window, the name of a customer, and so on.
Properties are a natural extension of fields. Both are named members with associated types, and the syntax
for accessing fields and properties is the same. However, unlike fields, properties do not denote storage
locations. Instead, properties have accessors that specify the statements to be executed when their values are
read or written.
Properties are defined with property declarations. The first part of a property declaration looks quite similar
to a field declaration. The second part includes a get accessor and/or a set accessor.
Properties that can be both read and written, include both get and set accessors. The get accessor is called
when the property's value is read; the set accessor is called when the property's value is written. In a set
accessor, the new value for the property is made available via an implicit parameter named value.

89. What is Stored Procedure


A stored procedure is a set of one or more SQL statements that are stored together in database. To create a
stored procedure use CREATE PROCEDURE statement. To use the stored procedure you send a request for
it to be executed. When server recieves the request, it executes the stored procedure.
Stored procedures assist in achieving a consistent implementation of logic across applications. The SQL
statements and logic needed to perform a commonly performed task can be designed, coded, and tested once
in a stored procedure. Each application needing to perform that task can then simply execute the stored
procedure. Coding business logic into a single stored procedure also offers a single point of control for
ensuring that business rules are correctly enforced.
Stored procedures can also improve performance. Many tasks are implemented as a series of SQL
statements. Conditional logic applied to the results of the first SQL statements determines which subsequent
SQL statements are executed. If these SQL statements and conditional logic are written into a stored
procedure, they become part of a single execution plan on the server. The results do not have to be returned
to the client to have the conditional logic applied; all of the work is done on the server.
There are some concepts of stored procedures.
• A stored procedure is one or more SQL statements that have been compiled and stored with
database. A stored procedure can be started by application code on the client.
• Stored procedure can improve database performance because the SQL statements in each procedure
are only compiled and optimized the first time they are executed. In sontrast SQL statements that are
sent from a client to the server have to be compiled and optimized everytime ther are executed.
• In addition to SELECT statement, a stored procedure can contain othe SQL statements such as
INSERT,UPDATE,DELETE. It also contain control-of-flow language.
• A trigger is a special type of procedure that executes when rows are inserted, updated or deleted from
table.
• A user defined function(UDF) is a special type of procedure that can return a value or a table.
01. What is Namespace?
02. How does the code written in different languages get executed in .net?
03. What is an application domain?
04. What are Generics in .Net framework 2.0?
05. What is an assembly in .NET Framework?
06. What is assembly manifest?
07. Explain the information stored in assembly manifest.
08. What are the functions performed by the assembly manifest?
09. Where are shared assemblies stored?
10. What is GAC (Global Assembly Cache)?
11. Where's global assembly cache located on the system?
12. What are the ways to deploy an assembly into the (GAC) global assembly cache?
13. What is the purpose of ILdasm.exe (Intermediate Language Disassembler)?
14. What is the difference between a private assembly and a shared assembly?
15. What is the difference between struct and class in C#?
16. How do I call one constructor from another in C#?
17. Comparison Between Properties and Indexers
18. Which interface(s) must a class implement in order to support the foreach statement?
19. Explain Abstract, Sealed, and Static Modifiers in C#.
20. What's the difference between override and new in C#?
21. Name two ways that you can prevent a class from being instantiated.
22. Explain some features of interface in C#.
23. Can an abstract class have non-abstract methods?
24. How do I use an alias for a namespace or class in C#?
25. What type of class cannot be inherited?
26. What keyword must a derived class use to replace a non-virtual inherited method?
27. Explain Web.config Settings for exception management in ASP.NET.
28. Why should you avoid the excessive use of ViewState in Asp.Net web page?
29. Explain the concept of Web Application.
30. What is difference between Response.Redirect and Server.Transfer?
31. What is a bubbled event in ASP.NET server side controls?
32. What is smart navigation in ASP.NET Pages?
33. What method do you use to explicitly kill a users session in ASP.NET?
34. What does the "EnableViewState" property do? Why would I want it on or off?
35. What are the different modes for the sessionstates in the web.config file?
36. Which two properties are on every validation control?
37. What is ASP.NET?
38. What are main parts of ASP.NET?
39. What is the difference between code inline and code behind models in Asp.Net?
40. What are the ways to manage state in Asp.Net application?
41. Explain the limitation & issues with the Cookies?
42. Explain the Limitations & Issues with Automatic SQL Server State Management?
43. What is the purpose of Server.MapPath method in Asp.Net?
44. Introduction to Web Service Methods in ASP.NET.
45. Explain WebMethod Attribute in Asp.Net Web Service.
46. What are the web services in ASP.NET?
47. What is the use of SOAP (Simple Object Access Protocol) in .Net Web Services?
48. Can you use User-Defined Types in Web Services?
49. What is WSDL?
50. What are the major elements of WSDL Document?
51. What is UDDI?
52. How do people use UDDI?
53. What is the UDDI Business Registry (UBR)?
54. What is ADO.NET?
55. What are the main classes/Components of ADO.NET?
56. Explain How ADO.NET Works?
57. What is DataSet?
58. What are the fundamental parts of DataSet?
59. What is the use of DataAdapter Class?
60. Which DataAdapters are available for use with different Databases in ADO.NET?
61. How can you update Database using DataAdapter and the DataSet?
62. Explain the Use of connection pooling in ADO.NET
63. How can you search the Data in DataSet?
64. How to set the Focus on control in ASP.NET?
65. How to set default button on a Web Form?
66. What is Partial Classes in Asp.Net 2.0?
67. What are the new features in ASP.NET 2.0?
68. What is the use of Tree View Control in ASP.NET 2.0?
69. What is the use of Master Pages in ASP.NET 2.0?
70. What is polymorphism in Object Oriented Programming (OOPS) Languages?
71. What is a Virtual Functions in class?
72. What is Encapsulation in Object Oriented Programming (OOPS) Languages?
73. Explain the advantages of Encapsulation in Object Oriented Programming Languages.
74. Limitations and Restrictions of Interface
75. What is an Object?
76. What is inheritance?
77. Explain some characteristics of inheritance.
78. What is an Interface in Microsoft.Net?
79. What is the difference between abstract class and interface?
80. What is a static class?
81. What is static member of class?
82. What is a field?
83. What is the difference between value parameter and reference parameter?
84. What is the use of parameter array?
85. What is the difference between reference parameter and output parameter?
86. What is a constant?
87. What is the method of class?
88. What is the property of class?
89. What is Stored Procedure

You might also like