Sunday, October 26, 2008

Dot net FAQ's

1. What is the difference between int and Int32?

Int32 is a class of namespace System. Keyword "int" is the alias of the class. So there is no real difference.

2. What does mutable and immutable means?

Immutable objects (read-only) are objects whose value cannot be modified once it has been created. Methods that appear to modify an immutable object actually return a new object that contains the modification (the previous object remains in memory until garbage collected).

Mutable Objects are objects whose value can be modified.

3. What is the difference between String class and StringBuilder class? Which one is better?

String Class is immutable and StringBuilder class is mutable. If the object has many operations involved then StringBuilder class is a better option.

4. What is CLR? Who loads the CLR into a process?

Common Language Runtime (CLR) is the commercial implementation of the specification Common Language Infrastructure (CLI). The Common Language Infrastructure (CLI) is an open specification developed by Microsoft that describes the executable code and runtime environment. The CLR is the platform on which the complete .NET Framework has been developed.

Hosts will load the CLR into the process.

5. What is difference between delegates and Events?

A delegate is a reference to a method. A delegate is raw in its nature, but an event is hooked up with a control; it acts based on the behavior of the control. An event is a delegate, but a delegate is not an event. Event = Delegate + Event handling logic.

6. What is a partial class?

A Partial class is a class that can be split into two or more classes. This means that a class can be physically separated into other parts of the class within the same namespace. All the parts must use the partial keyword. All the other classes should also have the same access modifier. At the compile time, all the partial classes will be treated as a single class. Let us list some advantages of having partial classes.

· Allows a clean separation of business logic layer and the user interface.

· The UI code can be hidden from the developer.

· Makes the debugging easier.

7. What is a Sealed Class? Where is it used?

A sealed class is a class for which there will be no derived class. The keyword sealed ensures no overriding of members.

In general all the API and framework classes are made to be sealed classes.

8. What are Generics?

Generics are classes, structures, interfaces, and methods that have placeholders (type parameters) for one or more of the types they store or use. Using Generics, the type safety check burden will be on the compiler rather than developer. Hence, the Developer needs to write the code explicitly for checking type safety.

Listing 1

public class Generic

{

public T Field;

}

Generic g = new Generic();

g.Field = "Some Value";Listing 1 shows a simple example of Generics. The generic class defined has a field of the type T. The type T is initialized to be string.

9. What is the class name for accessing the Configuration in .NET 2.0?

The class name used for accessing configuration in .NET 2.0 is ConfigurationManager. The ConfigurationManager class is a static class which has all the methods for accessing application configuration file. For web applications we have WebConfigurationManager class. The WebConfigurationManager allows us to access machine and application information.

10. What is an Exception? What is the Base class for all the exception classes?

Exception is an unusual error condition that occurs during the execution of a program or an application. Whenever an exception occurs, the .NET runtime throws an object of type "Exception." All the Exceptions thrown by .NET runtime have their base class as Exception. For more information of handling exceptions please refer the article Exception Handling in .NET 2.0.

11. What is an Assembly?

An assembly is a basic building block for any application in the .NET Framework. It is a fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the Common Language Runtime (CLR) with the information it needs to be aware of type implementations. During runtime, a type does not exist outside the context of an assembly.

The contents of an assembly are the following.

· CIL – Common Intermediate Language (formerly MSIL - Microsoft Intermediate Language)

· Assembly Manifest – The Assembly Manifest has the information like Name, Version number, Culture, Strong Name information, etc.

· Type Metadata

· Resources

12. What is a Satellite Assembly?

Satellite Assembly is a .NET Framework assembly containing resources specific to a given language. Using a satellite assembly, we can place resources of different languages in different assemblies and the correct assembly is loaded into memory only if the user elects to view the application in that language.

13. What is a .NET module? How is a .NET module different from an Assembly?

A .NET module is a portable executable file of type.dll or .exe consisting of one or more classes. This is similar to a .NET assembly which consists of classes, namespaces, etc.

A .NET module can not be deployed alone. It has to be linked into an assembly. This can be done by using compiler’s /add module switch (if the compiler supports it), al.exe, or in .NET Framework 2.0, link.exe.

14. Can we programmatically write an Assembly?

Yes, we can programmatically write any assembly.

15. What is CodeDOM in .NET used for?

CodeDOM is an API that helps in creating and compiling a programming structure at Runtime. Creating a programming structure involves creation of Namespace, Type – Class, Interface and even methods at the Runtime. The implementation of CodeDOM can be divided in the two ways shown below. The namespace for the CodeDOM is System.CodeDOM.

· Compiling or Building the Programs at the Runtime

· Using CodeDOM for generating a Program structure

16. Life cycle of ASP.NE T 2.0 Page

Life cycle of the page is defined as the list of events that get fired from the Page initialization to page rendering. The list of events is illustrated along with the descriptions.

Name of the Event

When does the event fire

PreInit

Occurs at the beginning of page initialization.

Init

Occurs when the server control is initialized, which is the first step in its lifecycle.

InitComplete

Occurs when page initialization is complete.

PreLoad

Occurs before the page Load event.

Load

Occurs when the server control is loaded into the Page object.

PreRender

Occurs after the Control object is loaded, but prior to rendering.

PreRenderComplete

Occurs before the page content is rendered.

SaveStateComplete

Occurs after the page has completed saving all view state and control state information for the page and controls on the page.

LoadComplete

Occurs at the end of the load stage of the page's life cycle.

Unload

Occurs when the server control is unloaded from memory.

17. What is the Pre-Compilation feature of ASP.NET 2.0? How does the new folder structure help for the same?

By default, ASP.NET Web pages and code files are compiled dynamically when users first request a resource such as a page from the Web site. After pages and code files have been compiled the first time, the compiled resources are cached, so that subsequent requests to the same page are extremely efficient. This was in previous versions of ASP.NET, but in ASP.NET 2.0 we have a feature called as pre-compilation. With this, ASP.NET can also pre-compile an entire site before it is made available to users. We have some pre-defined folder structures for enabling this feature of pre-compilation. Let us list down some of the folders with a brief description of what they are meant for.

App_Code – meant for storing classes

App_Themes – meant for storing CSS files, Images, etc.

App_Data –meant for storing XML files, Text Files, etc.

App_GlobalResources – meant for storing all the resources at global level E.g. resx files, etc

App_LocalResources – meant for storing all the resources at local/Page level

18. What is Authentication in ASP.NET?

Authentication is the process of identifying a user with identification credentials like User name and Password with some authority. Generally after authentication the system gets to know who the user is. ASP.Net has some authentication providers. Let us discuss some of them.

Windows Authentication Provider - Windows authentication in conjunction with Microsoft Internet Information Services (IIS) authentication to secure ASP.NET applications

Forms Authentication Provider – An application-specific login form and performs authentication using user code.

Passport Authentication provider – Centralized authentication service provided by Microsoft offers a single login and core profile service for member sites.

19. What is Authorization in ASP.NET?

Authorization determines whether an identity/user should be granted access to a specific resource. Authorization requires that the authentication is already done. There are 2 ways to authorize access to a given resource:

· File authorization - File authorization is performed by the FileAuthorizationModule. It checks the access control list (ACL) of the .aspx or .asmx handler file to determine whether a user should have access to the file.

· URL authorization - URL authorization is performed by the UrlAuthorizationModule, which maps users and roles to URLs in ASP.NET applications.

Listing 2

<[allow|deny] users roles verbs />

20. What is ASP.NET?

ASP.NET is a server-side technology for creating dynamic, standards-based Web sites and services that are accessible across multiple platforms including mobile devices. It is part of the .NET-based environment; you can author applications in any .NET compatible language, including Visual Basic .NET, C#, and J#. Additionally, the entire .NET Framework class library is available to any ASP.NET application. Developers can easily access the benefits of these technologies, which include the managed common language runtime environment, type safety, inheritance, and so on.

21. Whats the difference between ASP and ASP.NET?

ASP (Active Server Pages) and ASP.NET are both server side technologies for building web sites and Web applications, but ASP.NET is not simply a new version of ASP. ASP.NET has been entirely re-architected to provide a highly productive programming experience based on the .NET Framework, and a robust infrastructure for building reliable and scalable web applications.

22. How do I get ASP.NET?

You can get ASP.NET by installing the Microsoft .NET Framework. The .NET Framework is available in either a redistributable or SDK format.

23. How much does ASP.NET cost?

ASP.NET is part of the Microsoft .NET Framework. The .NET Framework is a feature of Windows, and is available for download at no charge from this site. You can develop ASP.NET sites using a text editor, but if youre looking for a development tool please see

24. Which development tools support ASP.NET? What operating systems does ASP.NET run on?

ASP.NET runs on Windows Server 2000, Windows Server 2003, and Windows XP Professional. Windows XP Home is also supported for development only using Visual Web Developer Express Edition tool (which is available for download) or Visual Studio 2005.

25. Can I develop my ASP.NET pages in Notepad, or do I need to buy Visual Studio?

Yes, you can use any text editor to create ASP.NET pages. However, you may find yourself more productive if you use a dedicated tool, such as Visual Web Developer Express Edition or Visual Studio.

26. I've installed the .NET Framework, but ASP.NET doesn't seem to work. What can I do to fix it?

You must have IIS (Internet Information Services) installed before you install the .NET Framework. If you install IIS after you install the .NET Framework, you must also register the ASP.NET extensions with IIS. You can do this by running the aspnet_regiis executable from: %windows root directory%\Microsoft.NET\Framework\%version of the .NET Framework%\aspnet_regiis -r where %windows root directory% is the directory Windows is installed to (typically c:\windows or c:\winnt) and %version of the .NET Framework% is the version of the .NET Framework you have installed. The directory for .NET 1.0 is v1.0.3705, for 1.1 is v1.1.4322, and for 2.0 is v2.0.50727.

27. Where should I put the connection string to my database for my ASP.NET app?

Keep in mind that securing your connection string will prevent hackers from accessing information in your databases. For v1.x, the section titled Storing Database Connection Strings Securely from Building Secure ASP.NET Applications: Authentication, Authorization, and Secure Communication outlines many good techniques for protecting this valuable resource. For v2.0, the walkthrough Encrypting Configuration Information Using Protected Configuration introduces Protected Configuration and the new connectionStrings configuration section as the preferred solution for storing connection string information in configuration files.

28. Which development tools support ASP.NET?

You can develop ASP.NET sites in any text editor, but Microsoft Visual Studio and Visual Web Developer Express Edition (available for download) provide rich support for the complete ASP.NET platform making development more productive and efficient. As well, Macromedia Dreamweaver MX and Borland C# Builder also offer ASP.NET development support.

29. Gridview in 2.0

The GridView control features automatic data binding; auto-generation of buttons for selecting, editing, and deleting; automatic sorting; and automatic paging. There is full backward compatibility for the DataGrid control, and pages that use the DataGrid will continue to work as they did in version 1.0 of ASP.NET.

30. Is the code in single-file and code-behind pages identical?

Almost. A code-behind file contains an explicit class declaration, which is not required for single-file pages.

31. Do I have to use one programming language for all my Web pages?

No. Each page can be written in a different programming language if you want, even in the same application. If you are creating source code files and putting them in the \App_Code folder to be compiled at run time, all the code in must be in the same language. However, you can create subfolders in the \App_Code folder and use the subfolders to store components written in different programming languages.

32. Can I hide the source code for my page?

Server-side code is processed on the server and is not sent to the browser, so users cannot see it. However, client script is not protected; any client script that you add to your page, or that is injected into the page by server processing, is visible to users. If you are concerned about protecting your source code on the server, you can precompile your site and deploy the compiled version.

33. Do I need IIS to run Web applications?

If you are using Visual Studio, you can use the ASP.NET Development Server built into Visual Studio to test your pages. The server functions as a local Web server, running ASP.NET Web pages in a manner virtually identical to how they run in IIS. To deploy a Web application, you need to copy it to a computer running IIS version 5 or 6.

34. How is ASP.NET configuration data formatted?

ASP.NET configuration data is encoded in XML and stored as plaintext files. You can access these files programmatically by using administration tools or by using a text editor.

35. Where are the ASP.NET configuration files stored?

System-wide configuration settings and some ASP.NET schema settings are stored in a file named Machine.config, which is located in the %SystemRoot%\Microsoft .NET\Framework\versionNumber\CONFIG directory. This directory also contains other default settings for ASP.NET Web applications in a file that is referred to as the root Web.config file. ASP.NET configuration files for individual Web sites and applications, which are also named Web.config files, can be stored in any Web site root directory, application root directory, application subdirectory, or all of these.

36. I used the ASP.NET configuration system to restrict access to my ASP.NET application, but anonymous users can still view some of my files. Why is that?

The features of the ASP.NET configuration system only apply to ASP.NET resources. For example, Forms Authentication only restricts access to ASP.NET files, not to static files or ASP (classic) files unless those resources are mapped to ASP.NET file name extensions. Use the configuration features of IIS to configure non-ASP.NET resources.

37. Since there can be multiple ASP.NET configuration files on one computer, how does ASP.NET configuration handle inheritance?

ASP.NET integrates the settings in configuration files (the Machine.config and Web.config files) into a single inheritance hierarchy. With a few exceptions, you can place a Web.config file wherever you need to override the configuration settings that are inherited from a configuration file located at a higher level in the hierarchy.

38. What happens when a configuration setting changes during run time?

ASP.NET invalidates the existing cache and assembles a new cache. Then ASP.NET automatically restarts the application to apply the changes.

39. How can I get programmatic access to ASP.NET configuration settings?

You can read, create, or modify configuration settings from within an ASP.NET application by using the ASP.NET management API. You can develop your own applications including Web applications, console applications, and scripts that use the management API.

40. How are ASP.NET configuration files secured against unauthorized access?

ASP.NET configures IIS to deny access to any user that requests access to the Machine.config or Web.config files.

41. What are the limitations when configuring ASP.NET by using the ASP.NET MMC snap-in?

The ASP.NET MMC snap-in allows you to set ASP.NET configuration at all levels, but on the local computer only.

42. How do I calculate a MD5 hash from a string?

It is a common practice to store passwords in databases using a hash. MD5 (defined in RFC 1321) is a common hash algorithm, and using it from C# is easy.

Here’s an implementation of a method that converts a string to an MD5 hash, which is a 32-character string of hexadecimal numbers.

public string CalculateMD5Hash(string input)

{

// step 1, calculate MD5 hash from input

MD5 md5 = System.Security.Cryptography.MD5.Create();

byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);

byte[] hash = md5.ComputeHash(inputBytes);

// step 2, convert byte array to hex string

StringBuilder sb = new StringBuilder();

for (int i = 0; i <>

{

sb.Append(hash[i].ToString("X2"));

}

return sb.ToString();

}

An example call:

string hash = CalculateMD5Hash("abcdefghijklmnopqrstuvwxyz");…returns a string like this:

C3FCD3D76192E4007DFB496CCA67E13B

43. Differences between an Abstract Class and Interface?

Abstract Class

Interface

1.May or maynot have abstract

methods. use virtual attribute in

class to implement Partial Implementation.

1.Can only have abstract methods, but

abstract Key word is not allowed.

2.Methods can have access modifiers.

(except Private Members.)

2.no access modifiers are allowed,

implicitly Public..`

3.can have fields, Properties and Methods.

3.can have only final constants,

Properties and Methods.

4.Can Extend a single class and implement one

or more Interfaces.

4.Can’t Extend a Class and can extend

a single or multiple interfaces.

*5.Abstract classes form part of the

Inheritance schema.

5.Interfaces do not .we can use same

interface in two projects that are not

related interms of Inheritance.

6.Can Have Constructor.

6.Can’t Have Constructor.

*7.Its Speed and Fast at Execution.

7.Slow at Execution.

*8.If you are Designing Large

Functional units

use an Abstract Class.

8.If you are designing small,Consise

bits of Functionality use Interfaces.

*9.If you want provide Common, Implemented functionality among

all implementations of ur Component,

use an Abstract Class.

9.If the Functionality you are creating

will be useful across a wide range of Disperate objects,use an Interface.

44. Basic Concepts of OOPs ?

1.DataAbstraction and Encapsulation.

2.Inheritence

3.Polymorphism.

1) Encapsulation: It is the mechanism that binds together code and data in manipulates, and keeps both safe from outside interference and misuse. In short it isolates a particular code and data from all other codes and data. A well-defined interface controls the access to that particular code and data.

2) Inheritance: It is the process by which one object acquires the properties of another object. This supports the hierarchical classification. Without the use of hierarchies, each object would need to define all its characteristics explicitly. However, by use of inheritance, an object need only define those qualities that make it unique within its class. It can inherit its general attributes from its parent. A new sub-class inherits all of the attributes of all of its ancestors.

3) Polymorphism: It is a feature that allows one interface to be used for general class of actions. The specificaction is determined by the exact nature of the situation. In general polymorphism means "one interface, multiple methods", This means that it is possible to design a generic interface to a group of related activities. This helps reduce complexity by allowing the same interface to be used to specify a general class of action. It is the compiler's job to select the specific action (that is, method) as it applies to each situation.

It’s an Example for LateBinding.

45. What are different types of Inheritance?

1.Single Inheritance:- Only One Base class and One derived Class

2.Multiple Inheritance:- Several Base Classes and a single Derived class

But this possible only with Interfaces and not with Base classes as a class can atmost extend a base class but can Implements more than one interfaces.

3.Hierarchical Inheritance:-One Base Class and many derived classes.

4.Multilevel Inheritance:-Derived from derived class.

46. What is Polymorphism?

Polymorphism means the ability to take more than one form.

Polymorphism means having Different implementation for the same method.

Polymorphism Plays an Important role in allowing Objects having different internal Structures to share the same external interface.

The benefit of Polymorphism is when the appropriate implementation is invoked automatically at runtime depending on the type of Object.

47. What is Interface?

Like class Interface contains, properties, methods, but interfaces doesn’t contain implementation of those methods.

Interface defines only Abstract Methods and Final fields.

An Interface represents a contract and a class that implements an Interface must implement every aspect of that interface exactly as it is defined.

An Interface is implemented and not extended.

1.A class can implement multiple interfaces.

2.An Interface can’t contain data declarations but you can declare properties.

3.All method declarations in an Interface are Public.

4.There can be no implementation in an Interface.

5.A class implementing the interface must provide implementation code.

6.An Interface can be derived from another Interface.

7.An Interface may not Contain DataMembers,Constructors and Destructors.

8.They can’t contain any static Members also.

9.They does not have any Acess Modifiers.

48. What is an Abstract Class?

An Abstract class is a class that contains methods that have no implementation(i.e abstract methods).

An abstract method is simply a shell or place-marker for a method that will be defined later in a derived class.

The intention of abstract methods is to force every derivation of the class to implement those methods. If a derived class does not implement an abstract method , then that class must also be declared as abstract.

An Abstract class is the class that can’t be instantiated(i.e no direct instances), but must be inherited from. (but whose descendents may have direct instances)

An Abstract class is usually partially implemented or not implemented at all, there by encapsulating common functionality for inherited classes.

NB:-Derived class is also called Concrete class. And Implementation of Abstract class is optional, unlike interface.

MustInherit-Class/MustOverridable-Method-vb.net

Abstract(Class&Method) –C#

49. Can I deploy the application without deploying the source code on the server?

Yes. You can obfuscate your code by using a new precompilation process called ‘precompilation for deployment’. You can use the aspnet_compiler.exe to precompile a site. This process builds each page in your web application into a single application DLL and some placeholder files. These files can then be deployed to the server.

You can also accomplish the same task using Visual Studio 2005 by using the Build->Publish menu.

50. Does ViewState affect performance? What is the ideal size of a ViewState? How can you compress a viewstate?

Viewstate stores the state of controls in HTML hidden fields. At times, this information can grow in size. This does affect the overall responsiveness of the page, thereby affecting performance. The ideal size of a viewstate should be not more than 25-30% of the page size.

Viewstate can be compressed to almost 50% of its size. .NET also provides the GZipStream or DeflateStream to compress viewstate. Another option is explained by Scott Hanselmann over here.

51. How can you detect if a viewstate has been tampered?

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

52. Can I use different programming languages in the same application?

Yes. Each page can be written with a different programming language in the same application. You can create a few pages in C# and a few in VB.NET.

53. Can the App_Code folder contain source code files in different programming languages?

No. All source code files kept in the root App_Code folder must be in the same programming language.

Update: However, you can create two subfolders inside the App_Code and then add both C# and VB.NET in the respective subfolders. You also have to add configuration settings in the web.config for this to work.

54. How do you secure your connection string information?

By using the Protected Configuration feature.

55. How do you secure your configuration files to be accessed remotely by unauthorized users?

ASP.NET configures IIS to deny access to any user that requests access to the Machine.config or Web.config files.

56. How can I configure ASP.NET applications that are running on a remote machine?

You can use the Web Site Administration Tool to configure remote websites.

57. How many web.config files can I have in an application?

You can keep multiple web.config files in an application. You can place a Web.config file inside a folder or wherever you need (apart from some exceptions) to override the configuration settings that are inherited from a configuration file located at a higher level in the hierarchy.

58. I have created a configuration setting in my web.config and have kept it at the root level. How do I prevent it from being overridden by another web.config that appears lower in the hierarchy?

By setting the element's Override attribute to false.

59. What is the difference between Response.Write and Response.Output.Write?

As quoted by Scott Hanselman, the short answer is that the latter gives you String.Format-style output and the former doesn't.

To get a detailed explanation, follow this link.

60. What is Cross Page Posting? How is it done?

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

61. Can you change a Master Page dynamically at runtime? How?

Yes. To change a master page, set the MasterPageFile property to point to the .master page during the PreInit page event.

62. How do you apply Themes to an entire application?

By specifying the theme in the web.config file.

Eg:

63. How do you exclude an ASP.NET page from using Themes?

To remove themes from your page, use the EnableTheming attribute of the Page directive.

Your client complains that he has a large form that collects user input. He wants to break the form into sections, keeping the information in the forms related. Which control will you use?

The ASP.NET Wizard Control.

To learn more about this control, visit this link.

64. Do webservices support data reader?

No. However it does support a dataset.

65.What is use of the AutoEventWireup attribute in the Page directive ?

The AutoEventWireUp is a boolean attribute that allows automatic wireup of page events when this attribute is set to true on the page. It is set to True by default for a C# web form whereas it is set as False for VB.NET forms. Pages developed with Visual Studio .NET have this attribute set to false, and page events are individually tied to handlers.

66.What happens when you change the web.config file at run time?

ASP.NET invalidates the existing cache and assembles a new cache. Then ASP.NET automatically restarts the application to apply the changes.

67. Can you programmatically access IIS configuration settings?

Yes. You can use ADSI, WMI, or COM interfaces to configure IIS programmatically.

68. How does Application Pools work in IIS 6.0?

As explained under the IIS documentation, when you run IIS 6.0 in worker process isolation mode, you can separate different Web applications and Web sites into groups known as application pools. An application pool is a group of one or more URLs that are served by a worker process or set of worker processes. Any Web directory or virtual directory can be assigned to an application pool.

Every application within an application pool shares the same worker process. Because each worker process operates as a separate instance of the worker process executable, W3wp.exe, the worker process that services one application pool is separated from the worker process that services another. Each separate worker process provides a process boundary so that when an application is assigned to one application pool, problems in other application pools do not affect the application. This ensures that if a worker process fails, it does not affect the applications running in other application pools.

Use multiple application pools when you want to help ensure that applications and Web sites are confidential and secure. For example, an enterprise organization might place its human resources Web site and its finance Web site on the same server, but in different application pools. Likewise, an ISP that hosts Web sites and applications for competing companies might run each companys Web services on the same server, but in different application pools. Using different application pools to isolate applications helps prevent one customer from accessing, changing, or using confidential information from another customers site.

In HTTP.sys, an application pool is represented by a request queue, from which the user-mode worker processes that service an application pool collect the requests. Each pool can manage requests for one or more unique Web applications, which you assign to the application pool based on their URLs. Application pools, then, are essentially worker process configurations that service groups of namespaces.

Multiple application pools can operate at the same time. An application, as defined by its URL, can only be served by one application pool at any time. While one application pool is servicing a request, you cannot route the request to another application pool. However, you can assign applications to another application pool while the server is running.

69. What is an application server?

As defined in Wikipedia, an application server is a software engine that delivers applications to client computers or devices. The application server runs your server code. Some well known application servers are IIS (Microsoft), WebLogic Server (BEA), JBoss (Red Hat), WebSphere (IBM).

70. What is a base class and derived class?

A class is a template for creating an object. The class from which other classes derive fundamental functionality is called a base class. For e.g. If Class Y derives from Class X, then Class X is a base class.

The class which derives functionality from a base class is called a derived class. If Class Y derives from Class X, then Class Y is a derived class.

71. What is an extender class?

An extender class allows you to extend the functionality of an existing control. It is used in Windows forms applications to add properties to controls.

72. What is inheritance?

Inheritance represents the relationship between two classes where one type derives functionality from a second type and then extends it by adding new methods, properties, events, fields and constants.

C# support two types of inheritance:

· Implementation inheritance

· Interface inheritance

73. What is implementation and interface inheritance?

When a class (type) is derived from another class(type) such that it inherits all the members of the base type it is Implementation Inheritance.

When a type (class or a struct) inherits only the signatures of the functions from another type it is Interface Inheritance.

In general Classes can be derived from another class, hence support Implementation inheritance. At the same time Classes can also be derived from one or more interfaces. Hence they support Interface inheritance.

74. What is inheritance hierarchy?

The class which derives functionality from a base class is called a derived class. A derived class can also act as a base class for another class. Thus it is possible to create a tree-like structure that illustrates the relationship between all related classes. This structure is known as the inheritance hierarchy.


75. How do you prevent a class from being inherited?

In VB.NET you use the NotInheritable modifier to prevent programmers from using the class as a base class. In C#, use the sealed keyword.

76. When should you use inheritance?

Inheritance is a useful programming concept, but it is easy to use inappropriately. Often interfaces do the job better. This topic and When to Use Interfaces help you understand when each approach should be used.

Inheritance is a good choice when:

  • Your inheritance hierarchy represents an "is-a" relationship and not a "has-a" relationship.
  • You can reuse code from the base classes.
  • You need to apply the same class and methods to different data types.
  • The class hierarchy is reasonably shallow, and other developers are not likely to add many more levels.
  • You want to make global changes to derived classes by changing a base class.

77. Define Overriding?

Overriding is a concept where a method in a derived class uses the same name, return type, and arguments as a method in its base class. In other words, if the derived class contains its own implementation of the method rather than using the method in the base class, the process is called overriding.

78. Can you use multiple inheritance in .NET?

.NET supports only single inheritance. However the purpose is accomplished using multiple interfaces.

79. Why don’t we have multiple inheritance in .NET?

There are several reasons for this. In simple words, the efforts are more, benefits are less. Different languages have different implementation requirements of multiple inheritance. So in order to implement multiple inheritance, we need to study the implementation aspects of all the languages that are CLR compliant and then implement a common methodology of implementing it. This is too much of efforts. Moreover multiple interface inheritance very much covers the benefits that multiple inheritance has.

80. What is an Interface?

An interface is a standard or contract that contains only the signatures of methods or events. The implementation is done in the class that inherits from this interface. Interfaces are primarily used to set a common standard or contract.

81. When should you use abstract class vs interface or What is the difference between an abstract class and interface?

I would suggest you to read this. There is a good comparison given over here.

82. What are events and delegates?

An event is a message sent by a control to notify the occurrence of an action. However it is not known which object receives the event. For this reason, .NET provides a special type called Delegate which acts as an intermediary between the sender object and receiver object.

83. What is business logic?

It is the functionality which handles the exchange of information between database and a user interface.

84. What is a component?

Component is a group of logically related classes and methods. A component is a class that implements the IComponent interface or uses a class that implements IComponent interface.

85.What is a control?

A control is a component that provides user-interface (UI) capabilities.

86. What are the differences between a control and a component?

The differences can be studied over here.

87. What are design patterns?

Design patterns are common solutions to common design problems.

88. What is a connection pool?

A connection pool is a ‘collection of connections’ which are shared between the clients requesting one. Once the connection is closed, it returns back to the pool. This allows the connections to be reused.

89. What is a flat file?

A flat file is the name given to text, which can be read or written only sequentially.

90. What are functional and non-functional requirements?

Functional requirements defines the behavior of a system whereas non-functional requirements specify how the system should behave; in other words they specify the quality requirements and judge the behavior of a system.

E.g.

Functional - Display a chart which shows the maximum number of products sold in a region.

Non-functional – The data presented in the chart must be updated every 5 minutes.

91. What is the global assembly cache (GAC)?

GAC is a machine-wide cache of assemblies that allows .NET applications to share libraries. GAC solves some of the problems associated with dll’s (DLL Hell).

92. What is a stack? What is a heap? Give the differences between the two?

Stack is a place in the memory where value types are stored. Heap is a place in the memory where the reference types are stored.

94. What is code review?

The process of examining the source code generally through a peer, to verify it against best practices.

95. What is logging?

Logging is the process of persisting information about the status of an application.

96. What is a Form?

A form is a representation of any window displayed in your application. Form can be used to create standard, borderless, floating, modal windows.

97. What is a multiple-document interface(MDI)?

A user interface container that enables a user to work with more than one document at a time. E.g. Microsoft Excel.

98. What is a single-document interface (SDI) ?

A user interface that is created to manage graphical user interfaces and controls into single windows. E.g. Microsoft Word

99. What is a private assembly?

A private assembly is local to the installation directory of an application and is used only by that application.

100. What is a shared assembly?

A shared assembly is kept in the global assembly cache (GAC) and can be used by one or more applications on a machine.

101. What is the difference between user and custom controls?

User controls are easier to create whereas custom controls require extra effort.

User controls are used when the layout is static whereas custom controls are used in dynamic layouts.

A user control cannot be added to the toolbox whereas a custom control can be.

A separate copy of a user control is required in every application that uses it whereas since custom controls are stored in the GAC, only a single copy can be used by all applications.

102. Where do custom controls reside?

In the global assembly cache (GAC).

103. What is a third-party control ?

A third-party control is one that is not created by the owners of a project. They are usually used to save time and resources and reuse the functionality developed by others (third-party).

104. What is a binary formatter?

Binary formatter is used to serialize and deserialize an object in binary format.

105. What is Boxing/Unboxing?

Boxing is used to convert value types to object.

E.g. int x = 1;

object obj = x ;

Unboxing is used to convert the object back to the value type.

E.g. int y = (int)obj;

Boxing/unboxing is quiet an expensive operation.

106. What is a COM Callable Wrapper (CCW)?

CCW is a wrapper created by the common language runtime(CLR) that enables COM components to access .NET objects.

107. What is a Runtime Callable Wrapper (RCW)?

RCW is a wrapper created by the common language runtime(CLR) to enable .NET components to call COM components.

108. What is a digital signature?

A digital signature is an electronic signature used to verify/gurantee the identity of the individual who is sending the message.

109. What is garbage collection?

Garbage collection is the process of managing the allocation and release of memory in your applications. Read this article for more information.

110. What is globalization?

Globalization is the process of customizing applications that support multiple cultures and regions.

111. What is localization?

Localization is the process of customizing applications that support a given culture and regions.

112. What is MIME?

The definition of MIME or Multipurpose Internet Mail Extensions as stated in MSDN is “MIME is a standard that can be used to include content of various types in a single message. MIME extends the Simple Mail Transfer Protocol (SMTP) format of mail messages to include multiple content, both textual and non-textual. Parts of the message may be images, audio, or text in different character sets. The MIME standard derives from RFCs such as 2821 and 2822”.

113. What is the Microsoft.NET?

.NET is a set of technologies designed to transform the internet into a full scale distributed platform. It provides new ways of connecting systems, information and devices through a collection of web services. It also provides a language independent, consistent programming model across all tiers of an application.

The goal of the .NET platform is to simplify web development by providing all of the tools and technologies that one needs to build distributed web applications.

114. What is the .NET Framework?

The .NET Framework is set of technologies that form an integral part of the .NET Platform. It is Microsoft's managed code programming model for building applications that have visually stunning user experiences, seamless and secure communication, and the ability to model a range of business processes.

The .NET Framework has two main components: the common language runtime (CLR) and .NET Framework class library. The CLR is the foundation of the .NET framework and provides a common set of services for projects that act as building blocks to build up applications across all tiers. It simplifies development and provides a robust and simplified environment which provides common services to build application. The .NET framework class library is a collection of reusable types and exposes features of the runtime. It contains of a set of classes that is used to access common functionality.

115. What is CLR?

The .NET Framework provides a runtime environment called the Common Language Runtime or CLR. The CLR can be compared to the Java Virtual Machine or JVM in Java. CLR handles the execution of code and provides useful services for the implementation of the program. In addition to executing code, CLR provides services such as memory management, thread management, security management, code verification, compilation, and other system services. It enforces rules that in turn provide a robust and secure execution environment for .NET applications.

116. What is CTS?

Common Type System (CTS) describes the datatypes that can be used by managed code. CTS defines how these types are declared, used and managed in the runtime. It facilitates cross-language integration, type safety, and high performance code execution. The rules defined in CTS can be used to define your own classes and values.

117. What is CLS?

Common Language Specification (CLS) defines the rules and standards to which languages must adhere to in order to be compatible with other .NET languages. This enables C# developers to inherit from classes defined in VB.NET or other .NET compatible languages.

118. What is managed code?

The .NET Framework provides a run-time environment called the Common Language Runtime, which manages the execution of code and provides services that make the development process easier. Compilers and tools expose the runtime's functionality and enable you to write code that benefits from this managed execution environment. The code that runs within the common language runtime is called managed code.

119. What is MSIL?

When the code is compiled, the compiler translates your code into Microsoft intermediate language (MSIL). The common language runtime includes a JIT compiler for converting this MSIL then to native code.

MSIL contains metadata that is the key to cross language interoperability. Since this metadata is standardized across all .NET languages, a program written in one language can understand the metadata and execute code, written in a different language. 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.

120. What is JIT?

JIT is a compiler that converts MSIL to native code. The native code consists of hardware specific instructions that can be executed by the CPU.

Rather than converting the entire MSIL (in a portable executable[PE]file) to native code, the JIT converts the MSIL as it is needed during execution. This converted native code is stored so that it is accessible for subsequent calls.

121. What is portable executable (PE)?

PE is the file format defining the structure that all executable files (EXE) and Dynamic Link Libraries (DLL) must use to allow them to be loaded and executed by Windows. PE is derived from the Microsoft Common Object File Format (COFF). The EXE and DLL files created using the .NET Framework obey the PE/COFF formats and also add additional header and data sections to the files that are only used by the CLR.

122. What is an application domain?

Application domain is the boundary within which an application runs. A process can contain multiple application domains. Application domains provide an isolated environment to applications that is similar to the isolation provided by processes. An application running inside one application domain cannot directly access the code running inside another application domain. To access the code running in another application domain, an application needs to use a proxy.

123. How does an AppDomain get created?

AppDomains are usually created by hosts. Examples of hosts are the Windows Shell, ASP.NET and IE. When you run a .NET application from the command-line, the host is the Shell. The Shell creates a new AppDomain for every application. AppDomains can also be explicitly created by .NET applications.

124. What is an assembly?

An assembly is a collection of one or more .exe or dll’s. An assembly is the fundamental unit for application development and deployment in the .NET Framework. An assembly contains a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the CLR with the information it needs to be aware of type implementations.

125. What are the contents of assembly?

A static assembly can consist of four elements:

· Assembly manifest - Contains the assembly metadata. An assembly manifest contains the information about the identity and version of the assembly. It also contains the information required to resolve references to types and resources.

· Type metadata - Binary information that describes a program.

· Microsoft intermediate language (MSIL) code.

· A set of resources.

126. What are the different types of assembly?

Assemblies can also be private or shared. A private assembly is installed in the installation directory of an application and is accessible to that application only. On the other hand, a shared assembly is shared by multiple applications. A shared assembly has a strong name and is installed in the GAC.

We also have satellite assemblies that are often used to deploy language-specific resources for an application.

127. What is a dynamic assembly?

A dynamic assembly is created dynamically at run time when an application requires the types within these assemblies.

128. What is a strong name?

You need to assign a strong name to an assembly to place it in the GAC and make it globally accessible. A strong name consists of a name that consists of an assembly's identity (text name, version number, and culture information), a public key and a digital signature generated over the assembly. The .NET Framework provides a tool called the Strong Name Tool (Sn.exe), which allows verification and key pair and signature generation.

129. What is GAC? What are the steps to create an assembly and add it to the GAC?

The global assembly cache (GAC) is a machine-wide code 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.

Steps

- Create a strong name using sn.exe tool eg: sn -k mykey.snk

- in AssemblyInfo.cs, add the strong name eg: [assembly: AssemblyKeyFile("mykey.snk")]

- recompile project, and then install it to GAC in two ways :

· drag & drop it to assembly folder (C:\WINDOWS\assembly OR C:\WINNT\assembly) (shfusion.dll tool)

· gacutil -i abc.dll

130. What is the caspol.exe tool used for?

The caspol tool grants and modifies permissions to code groups at the user policy, machine policy, and enterprise policy levels.

131. What is a garbage collector?

A garbage collector performs periodic checks on the managed heap to identify objects that are no longer required by the program and removes them from memory.

132. What are generations and how are they used by the garbage collector?

Generations are the division of objects on the managed heap used by the garbage collector. This mechanism allows the garbage collector to perform highly optimized garbage collection. The unreachable objects are placed in generation 0, the reachable objects are placed in generation 1, and the objects that survive the collection process are promoted to higher generations.

133. What is Ilasm.exe used for?

Ilasm.exe is a tool that generates PE files from MSIL code. You can run the resulting executable to determine whether the MSIL code performs as expected.

134. What is Ildasm.exe used for?

Ildasm.exe is a tool that takes a PE file containing the MSIL code as a parameter and creates a text file that contains managed code.

135. What is the ResGen.exe tool used for?

ResGen.exe is a tool that is used to convert resource files in the form of .txt or .resx files to common language runtime binary .resources files that can be compiled into satellite assemblies.

136. What’s new in C# ?

Introducing C# 2.0

With the release of Visual Studio 2005 (formerly codenamed Whidbey), C# is back with some new innovations. The C# language has been updated to version 2.0 and comes with several language extensions which we will explore in this 2 part series article. Besides Generic types, the C# language introduces some other interesting features such as Iterators, Partial Classes and Anonymous methods, which are briefly mentioned below.

Generics

Although new to the .NET platform, this concept has been around for years. Generics is a term used to describe generic types. It greatly enhances application performance and type safety and allows you to write highly general, flexible and safe code. It permits classes, interfaces, structs, delegates and methods to be parameterized by the types of data they store and manipulate.

Iterators

Iterators specify how a for-each loop will iterate over a collection and return its internal items. They allow you to create enumerable classes with minimum coding.

Partial Classes

Partial Classes allows you to split a single type, like your class, across more than one file (.cs). They are useful if you have extremely large, unwieldy types.

Nullable Types

Nullable types allow a variable to contain a value that is undefined. This is useful when working with databases where the value returned might be null

Anonymous Methods

Anonymous Methods Are Inline Delegates. It enables you to pass a block of code as a parameter. Anonymous methods enables you to directly associate a block of code statements to a given event. You use them anywhere a delegate is used . So there is no need to define a new method.

Namespace alias qualifier

C# 2.0 adds the namespace alias qualifier, the :: operator, to provide more control over accessing namespace members.

Static Classes

With C# 2.0, now you also can declare classes as static. This signals the compiler that this class should not be instantiated and can only contains static members.

Property Accessor Accessibility

C# 2.0 allows a fine control over the accessibility of accessors and indexers within a property.

Covariance and Contravariance in Delegates

The method passed to a delegate may now have greater flexibility in its return type and parameters.

137. Generics ?

Classes are templates that you can use to build new objects. Generics are templates that you can use to build new classes. This code template can be applied to use the same code repeatedly. A generic class is tied to one or more specific data types.

Generics permit classes, interfaces, structs, delegates and methods to be parameterized by the types of data they store and manipulate. They are Type-independent algorithms and collections. They enable programmers to achieve a high level of code reuse and enhanced performance for collection classes. Generics are defined with left and right brackets: . Here ‘T’ in is the name of the type that is going to be used.

Let me demonstrate the use of Generics by taking a simple example:

namespace GenericsDemo

{

class TestGenerics

{

static void Main(string[] args)

{

GenericsExample();

}

private void GenericsExample()

{

ClsGeneric intGeneric = new ClsGeneric(1000);

ClsGeneric strGeneric = new ClsGeneric("Voila");

ClsGeneric fGeneric = new ClsGeneric(23.38f);

ClsGeneric dGeneric = new ClsGeneric(444.4);

ClsGeneric bGeneric = new ClsGeneric(true);

}

}

public class ClsGeneric

{

public ClsGeneric(T Type)

{

Console.WriteLine("T over here is {0} ", typeof(T).ToString());

}

}

}

By using a generic type parameter T, you can write a single class that other client code can use without incurring the cost or risk of runtime casts or boxing operations.

138. Iterators ?

In the earlier versions of C#, in order to use the for-each loop, you need to implement the IEnumerable interface which in turn demands the implementation of the GetEnumerator() method. This method returns an IEnumerator object using which you can use the foreach loop.

An iterator on the other hand, enables you to support foreach iteration in a class or struct without having to implement the entire IEnumerable interface.

Let me demonstrate this with an example :

public class StringCollection : System.Collections.IEnumerable

{

string[] names = { "Tom", "Dick", "Harry”, "Ralph", "Jack", "Jill” };

public System.Collections.IEnumerator GetEnumerator()

{

for (int i = 0; i <>

{

yield return names[i];

// In C#1.x you would have specified it using

// return names[i].GetEnumerator();

}

}

}

class TestStringCollection

{

static void Main()

{

// Create an instance

StringCollection strNames = new StringCollection();

foreach (string name in strNames)

{

System.Console.WriteLine(name);

}

Console.WriteLine("Press any key to continue...");

Console.ReadKey();

}

}

Note: The new iterator pattern in C# 2.0 is significantly faster than its C# 1.x counterparts.

139. Partial Classes ?

C# 2.0 introduces the concept of partial type definitions for classes, structs, and interfaces that allows you to define a C# type across multiple *.cs files. This leads to easier maintenance and development as more than one developer can simultaneously write the code for the class.

public partial class A

{

public void methodA()

{

// Code for methodA

}

}

public partial class A

{

public void methodB()

{

// Code for methodB

}

}

140. Nullable Types ?

A type is said to be nullable if it can be assigned a value or can be assigned a null reference. This change makes it easier to integrate with databases, especially for fields that are optional.

A null type is very similar to its equivalent non-nullable type. The difference lies in how it is declared. For example : To declare an integer, you would declare it like this :

int iVal = 1; However in order to enable iVal to store a null value, you will declare it like this :

int? iVal = 1;

Now the way to define any valuetype as a nullable type is to define the generic System.Nullable type. So the syntax to define a nullable integer is:

System.Nullable iVal;

However this is somewhat difficult to read and that is why C# provides a cleaner syntax for the nullable type by adding a question mark to the immediate right of the type name when

defining a variable. The Syntax is [Value-Type]?

So System.Nullable iVal and int? iVal are equivalent. Similarly you can also assign it a value null and use the HasValue and Value read-only properties to test for null and retrieve the value. Here’s an example :

int? iVal = null;

if (iVal.HasValue == true)

{

System.Console.WriteLine("iVal = " + iVal.Value);

}

else

{

System.Console.WriteLine("iVal = Null");

}

141. Anonymous Methods

Anonymous methods help you reduce the coding overhead in instantiating delegates, by eliminating the need to create a separate method. This construct allows you to directly associate a block of code statements to a given event. In general, you can use anonymous methods anywhere you can use a delegate. An anonymous method consists of the keyword delegate, an optional parameter list, and a statement list enclosed in { and } delimiters. In some cases, the anonymous methods can omit the parameter list.

public class frmOld : Form

{

// This method connects the event handler.

public frmOld()

{

InitializeComponent();

btnOld.Click += new EventHandler(ButtonClick);

}

// This is the event handling method.

private void ButtonClick(object sender, EventArgs e)

{

MessageBox.Show("Old method of handling ButtonClick");

}

}

Using Anonymous methods :

public class frmNew : Form

{

public frmNew()

{

InitializeComponent();

btnNew.Click += delegate(object sender, EventArgs e)

{

MessageBox.Show(“New way of handling button click using anonymous methods");

};

}

}

// Declare a delegate

delegate void PrintHello(string str);

class TestAnonymous

{

static void Main()

{

hello = new PrintHello(TestAnonymous.TestMethod);

Without anonymous method you would associate the delegate with a named method. For eg:

hello = new PrintHello(TestAnonymous.TestMethod);

//and declared a method to associate it with the named delegate

static void TestMethod(string test)

{

System.Console.WriteLine(test);

}

142. Static Classes

Static classes are classes that contain only static members. These static members can be initialized only by using static constructors. The data and functions that these classes create, can be accessed without creating an instance of the class. Static classes are sealed so they can not be inherited. TheSystem.Math class is an example of this construct.

Static classes can be used when there is no data or behavior in the class that depends on object identity. One of the advantages of static classes is improved performance. Since there is no instantiation of object, the framework maintains a single object in memory for static members. They are loaded automatically by the .NET Framework common language runtime (CLR) when the program or namespace containing the class is loaded.

Creating a static class is much the same as creating a class that contains only static members and a private constructor. A private constructor prevents the class from being instantiated. Lets see an example of a static class.

143. Property Accessor Accessibility

Properties provide flexibility to read and write the values of private fields. They can be used as though they are public data members, but they are actually special methods called accessors. This enables data to be accessed easily while still providing the safety and flexibility of methods.

In C# 1.x, we declare a property in our class in the following manner:

class ClsProp

{

private string strMyName = "Suprotim";

public string StrMyName

{

get { return strMyName; }

set { strMyName = value; }

}

}

Here the ‘get’ and the ‘set’ accessors have the same accessibility level i.e., they are both ‘public’ as the property itself is ‘public’. However, it is sometimes useful to restrict access to one of these accessors, which was not possible for us in C# 1.x.

In C# 2.0, this has changed :

public string StrMyName

{

get

{

return strMyName;

}

protected set

{

strMyName = value;

}

}

In this example, a property called StrMyName defines a get and set accessor. The get accessor receives the accessibility level of the property itself, public in this case, while the set accessor is explicitly restricted by applying the protected access modifier to the accessor itself.

Note : This feature of having Accessor Accessibility was provided in C# v1.0 beta. However Microsoft removed it before the C# v1.0 RTM as they felt it was too complicated for developers. In C# 2.0, it has been re-introduced.

Covariance and Contravariance

In .NET 1.1, delegates could only be created with methods whose arguments strictly matched the signature of that delegate. With .NET 2.0, Covariance and contravariance provide a degree of flexibility when matching delegate methods with delegate signatures.

144. What is ASP.NET?

Microsoft ASP.NET is a server side technology that enables programmers to build dynamic Web sites, web applications, and XML Web services. It is a part of the .NET based environment and is built on the Common Language Runtime (CLR) . So programmers can write ASP.NET code using any .NET compatible language.

145. What are the differences between ASP.NET 1.1 and ASP.NET 2.0?

A comparison chart containing the differences between ASP.NET 1.1 and ASP.NET 2.0 can be found over here.

146. Which is the latest version of ASP.NET? What were the previous versions released?

The latest version of ASP.NET is 2.0. There have been 3 versions of ASP.NET released as of date. They are as follows :

ASP.NET 1.0 – Released on January 16, 2002.

ASP.NET 1.1 – Released on April 24, 2003.

ASP.NET 2.0 – Released on November 7, 2005.

Additionally, ASP.NET 3.5 is tentatively to be released by the end of the 2007.

147. Explain the Event Life cycle of ASP.NET 2.0?

The events occur in the following sequence. Its best to turn on tracing(<% @Page Trace=”true”%>) and track the flow of events :

PreInit – This event represents the entry point of the page life cycle. If you need to change the Master page or theme programmatically, then this would be the event to do so. Dynamic controls are created in this event.

Init – Each control in the control collection is initialized.

Init Complete* - Page is initialized and the process is completed.

PreLoad* - This event is called before the loading of the page is completed.

Load – This event is raised for the Page and then all child controls. The controls properties and view state can be accessed at this stage. This event indicates that the controls have been fully loaded.

LoadComplete* - This event signals indicates that the page has been loaded in the memory. It also marks the beginning of the rendering stage.

PreRender – If you need to make any final updates to the contents of the controls or the page, then use this event. It first fires for the page and then for all the controls.

PreRenderComplete* - Is called to explicitly state that the PreRender phase is completed.

SaveStateComplete* - In this event, the current state of the control is completely saved to the ViewState.

Unload – This event is typically used for closing files and database connections. At times, it is also used for logging some wrap-up tasks.

The events marked with * have been introduced in ASP.NET 2.0.

148. You have created an ASP.NET Application. How will you run it?

With ASP.NET 2.0, Visual Studio comes with an inbuilt ASP.NET Development Server to test your pages. It functions as a local Web server. The only limitation is that remote machines cannot access pages running on this local server. The second option is to deploy a Web application to a computer running IIS version 5 or 6 or 7.

149. Explain the AutoPostBack feature in ASP.NET?

AutoPostBack allows a control to automatically postback when an event is fired. For eg: If we have a Button control and want the event to be posted to the server for processing, we can set AutoPostBack = True on the button.

150. How do you disable AutoPostBack?

Hence the AutoPostBack can be disabled on an ASP.NET page by disabling AutoPostBack on all the controls of a page. AutoPostBack is caused by a control on the page.

151. What are the different code models available in ASP.NET 2.0?

There are 2 code models available in ASP.NET 2.0. One is the single-file page and the other one is the code behind page.

152. Which base class does the web form inherit from?

Page class in the System.Web.UI namespace.

153. Which are the new special folders that are introduced in ASP.NET 2.0?

There are seven new folders introduced in ASP.NET 2.0 :

\App_Browsers folder – Holds browser definitions(.brower) files which identify the browser and their capabilities.

\App_Code folder – Contains source code (.cs, .vb) files which are automatically compiled when placed in this folder. Additionally placing web service files generates a proxy class(out of .wsdl) and a typed dataset (out of .xsd).

\App_Data folder – Contains data store files like .mdf (Sql Express files), .mdb, XML files etc. This folder also stores the local db to maintain membership and role information.

\App_GlobalResources folder – Contains assembly resource files (.resx) which when placed in this folder are compiled automatically. In earlier versions, we were required to manually use the resgen.exe tool to compile resource files. These files can be accessed globally in the application.

\App_LocalResources folder – Contains assembly resource files (.resx) which can be used by a specific page or control.

\App_Themes folder – This folder contains .css and .skin files that define the appearance of web pages and controls.

\App_WebReferences folder – Replaces the previously used Web References folder. This folder contains the .disco, .wsdl, .xsd files that get generated when accessing remote web services.

154. Explain the ViewState in ASP.NET?

Http is a stateless protocol. Hence the state of controls is not saved between postbacks. Viewstate is the means of storing the state of server side controls between postbacks. The information is stored in HTML hidden fields. In other words, it is a snapshot of the contents of a page.

You can disable viewstate by a control by setting the EnableViewState property to false.

155. What does the EnableViewState property signify?

EnableViewState saves the state of an object in a page between postbacks. Objects are saved in a Base64 encoded string. If you do not need to store the page, turn it off as it adds to the page size.

156. Explain the ASP.NET Page Directives?

Page directives configure the runtime environment that will execute the page. The complete list of directives is as follows:

@ Assembly - Links an assembly to the current page or user control declaratively.

@ Control - Defines control-specific attributes used by the ASP.NET page parser and compiler and can be included only in .ascx files (user controls).

@ Implements - Indicates that a page or user control implements a specified .NET Framework interface declaratively.

@ Import - Imports a namespace into a page or user control explicitly.

@ Master - Identifies a page as a master page and defines attributes used by the ASP.NET page parser and compiler and can be included only in .master files.

@ MasterType - Defines the class or virtual path used to type the Master property of a page.

@ OutputCache - Controls the output caching policies of a page or user control declaratively.

@ Page - Defines page-specific attributes used by the ASP.NET page parser and compiler and can be included only in .aspx files.

@ PreviousPageType - Creates a strongly typed reference to the source page from the target of a cross-page posting.

@ Reference - Links a page, user control, or COM control to the current page or user control declaratively.

@ Register - Associates aliases with namespaces and classes, which allow user controls and custom server controls to be rendered when included in a requested page or user control.

157. Explain the Validation Controls used in ASP.NET 2.0?

Validation controls allows you to validate a control against a set of rules. There are 6 different validation controls used in ASP.NET 2.0.

RequiredFieldValidator – Checks if the control is not empty when the form is submitted.

CompareValidator – Compares the value of one control to another using a comparison operator (equal, less than, greater than etc).

RangeValidator – Checks whether a value falls within a given range of number, date or string.

RegularExpressionValidator – Confirms that the value of a control matches a pattern defined by a regular expression. Eg: Email validation.

CustomValidator – Calls your own custom validation logic to perform validations that cannot be handled by the built in validators.

ValidationSummary – Show a summary of errors raised by each control on the page on a specific spot or in a message box.

158. How do you indentify that the page is post back?

By checking the IsPostBack property. If IsPostBack is True, the page has been posted back.

159. What are Master Pages?

Master pages is a template that is used to create web pages with a consistent layout throughout your application. Master Pages contains content placeholders to hold page specific content. When a page is requested, the contents of a Master page are merged with the content page, thereby giving a consistent layout.

160. How is a Master Page different from an ASP.NET page?

The MasterPage has a @Master top directive and contains ContentPlaceHolder server controls. It is quiet similar to an ASP.NET page.

161. How do you attach an exisiting page to a Master page?

By using the MasterPageFile attribute in the @Page directive and removing some markup.

How do you set the title of an ASP.NET page that is attached to a Master Page?

By using the Title property of the @Page directive in the content page. Eg:

<@Page MasterPageFile="Sample.master" Title="I hold content" %>

162. What is a nested master page? How do you create them?

A Nested master page is a master page associated with another master page. To create a nested master page, set the MasterPageFile attribute of the @Master directive to the name of the .master file of the base master page.

163. What are Themes?

Themes are a collection of CSS files, .skin files, and images. They are text based style definitions and are very similar to CSS, in that they provide a common look and feel throughout the website.

164. What are skins?

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

Defines a skin that will be applied to all buttons throughout to give it a consistent look and feel.

165. What is the difference between Skins and Css files?

Css is applied to HTML controls whereas skins are applied to server controls.

166. What is a User Control?

User controls are reusable controls, similar to web pages. They cannot be accessed directly.

Explain briefly the steps in creating a user control?

· Create a file with .ascx extension and place the @Control directive at top of the page.

· Included the user control in a Web Forms page using a @Register directive

167. What is a Custom Control?

Custom controls are compiled components that run on the server and that encapsulate user-interface and other related functionality into reusable packages. They can include all the design-time features of standard ASP.NET server controls, including full support for Visual Studio design features such as the Properties window, the visual designer, and the Toolbox.

168. What are the differences between user and custom controls?

User controls are easier to create in comparison to custom controls, however user controls can be less convenient to use in advanced scenarios.

User controls have limited support for consumers who use a visual design tool whereas custom controls have full visual design tool support for consumers.

A separate copy of the user control is required in each application that uses it whereas only a single copy of the custom control is required, in the global assembly cache, which makes maintenance easier.

A user control cannot be added to the Toolbox in Visual Studio whereas custom controls can be added to the Toolbox in Visual Studio.

User controls are good for static layout whereas custom controls are good for dynamic layout.

169. Where do you store your connection string information?


The connection string can be stored in configuration files (web.config).

170. What is the difference between ‘Web.config’ and ‘Machine.config’?

Web.config files are used to apply configuration settings to a particular web application whereas machine.config file is used to apply configuration settings for all the websites on a web server.

Web.config files are located in the application's root directory or inside a folder situated in a lower hierarchy. The machine.config is located in the Windows directory Microsoft.Net\Framework\Version\CONFIG.

There can be multiple web.config files in an application nested at different hierarchies. However there can be only one machine.config file on a web server.

171. What is the difference between Server.Transfer and Response.Redirect?

Response.Redirect involves a roundtrip to the server whereas Server.Transfer conserves server resources by avoiding the roundtrip. It just changes the focus of the webserver to a different page and transfers the page processing to a different page.

Response.Redirect can be used for both .aspx and html pages whereas Server.Transfer can be used only for .aspx pages.

Response.Redirect can be used to redirect a user to an external websites. Server.Transfer can be used only on sites running on the same server. You cannot use Server.Transfer to redirect the user to a page running on a different server.

Response.Redirect changes the url in the browser. So they can be bookmarked. Whereas Server.Transfer retains the original url in the browser. It just replaces the contents of the previous page with the new one.

172. What method do you use to explicitly kill a users session?

Session.Abandon().

173. What is a webservice?

Web Services are applications delivered as a service on the Web. Web services allow for programmatic access of business logic over the Web. Web services typically rely on XML-based protocols, messages, and interface descriptions for communication and access. Web services are designed to be used by other programs or applications rather than directly by end user. Programs invoking a Web service are called clients. SOAP over HTTP is the most commonly used protocol for invoking Web services.

174. What is Ajax?

The term Ajax was coined by Jesse James Garrett and is a short form for "Asynchronous Javascript and XML". Ajax represents a set of commonly used techniques, like HTML/XHTML, CSS, Document Object Model(DOM), XML/XSLT, Javascript and the XMLHttpRequest object, to create RIA's (Rich Internet Applications).

Ajax gives the user, the ability to dynamically and asynchronously interact with a web server, without using a plug-in or without compromising on the user’s ability to interact with the page. This is possible due to an object found in browsers called the XMLHttpRequest object.

175. What is ASP.NET AJAX?

‘ASP.NET AJAX’ is a terminology coined by Microsoft for ‘their’ implementation of AJAX, which is a set of extensions to ASP.NET. These components allow you to build rich AJAX enabled web applications, which consists of both server side and client side libraries.

176. Which is the current version of ASP.NET AJAX Control Toolkit?

As of this writing, the toolkit version is Version 1.0.20229 (if you are targeting Framework 2.0, ASP.NET AJAX 1.0 and Visual Studio 2005) and Version 3.0.20229 (if targeting .NET Framework 3.5 and Visual Studio 2008).

177. What role does the ScriptManager play?

The ScriptManager manages all ASP.NET AJAX resources on a page and renders the links for the ASP.NET AJAX client libraries, which lets you use AJAX functionality like PageMethods, UpdatePanels etc. It creates the PageRequestManager and Application objects, which are prominent in raising events during the client life cycle of an ASP.NET AJAX Web page. It also helps you create proxies to call web services asynchronously.

178. Can we use multiple ScriptManager on a page?

No. You can use only one ScriptManager on a page.

179. What is the role of a ScriptManagerProxy?

A page can contain only one ScriptManager control. If you have a Master-Content page scenario in your application and the MasterPage contains a ScriptManager control, then you can use the ScriptManagerProxy control to add scripts to content pages.

Also, if you come across a scenario where only a few pages in your application need to register to a script or a web service, then its best to remove them from the ScriptManager control and add them to individual pages, by using the ScriptManagerProxy control. That is because if you added the scripts using the ScriptManager on the Master Page, then these items will be downloaded on each page that derives from the MasterPage, even if they are not needed, which would lead to a waste of resources.

180. What are the requirements to run ASP.NET AJAX applications on a server?


You would need to install ‘ASP.NET AJAX Extensions’ on your server. If you are using the ASP.NET AJAX Control toolkit, then you would also need to add the AjaxControlToolkit.dll in the /Bin folder.

Note: ASP.NET AJAX 1.0 was available as a separate downloadable add-on for ASP.NET 2.0. With ASP.NET 3.5, the AJAX components have been integrated into ASP.NET.

181. Explain the UpdatePanel?

The UpdatePanel enables you to add AJAX functionality to existing ASP.NET applications. It can be used to update content in a page by using Partial-page rendering. By using Partial-page rendering, you can refresh only a selected part of the page instead of refreshing the whole page with a postback.

182. Can I use ASP.NET AJAX with any other technology apart from ASP.NET?

To answer this question, check out this example of using ASP.NET AJAX with PHP, to demonstrate running ASP.NET AJAX outside of ASP.NET. Client-Side ASP.NET AJAX framework can be used with PHP and Coldfusion.

183. How can you cancel an Asynchronous postback?

Yes you can. Read my article over here.

184. Difference between Server-Side AJAX framework and Client-side AJAX framework?

ASP.NET AJAX contains both a server-side Ajax framework and a client-side Ajax framework. The server-side framework provides developers with an easy way to implement Ajax functionality, without having to possess much knowledge of JavaScript. The framework includes server controls and components and the drag and drop functionality. This framework is usually preferred when you need to quickly ajaxify an asp.net application. The disadvantage is that you still need a round trip to the server to perform a client-side action.

The Client-Side Framework allows you to build web applications with rich user-interactivity as that of a desktop application. It contains a set of JavaScript libraries, which is independent from ASP.NET. The library is getting rich in functionality with every new build released.

185. How can you debug ASP.NET AJAX applications?

Explain about two tools useful for debugging: Fiddler for IE and Firebug for Mozilla.

186. Can we call Server-Side code (C# or VB.NET code) from javascript?

Yes. You can do so using PageMethods in ASP.NET AJAX or using webservices.

187. Can you nest UpdatePanel within each other?

Yes, you can do that. You would want to nest update panels to basically have more control over the Page Refresh.

188. How can you to add JavaScript to a page when performing an asynchronous postback?

Use the ScriptManager class. This class contains several methods like the RegisterStartupScript(), RegisterClientScriptBlock(), RegisterClientScriptInclude(), RegisterArrayDeclaration(),RegisterClientScriptResource(), RegisterExpandoAttribute(), RegisterOnSubmitStatement() which helps to add javascript while performing an asynchronous postback.

189. Explain differences between the page execution lifecycle of an ASP.NET page and an ASP.NET AJAX page?

In an asynchronous model, all the server side events occur, as they do in a synchronous model. The Microsoft AJAX Library also raises client side events. However when the page is rendered, asynchronous postback renders only the contents of the update panel, where as in a synchronous postback, the entire page is recreated and sent back to the browser.

190. Explain the AJAX Client life-cycle events

Here’s a good article about the same.

191. Is the ASP.NET AJAX Control Toolkit(AjaxControlToolkit.dll) installed in the Global Assembly Cache?

No. You must copy the AjaxControlToolkit.dll assembly to the /Bin folder in your application.

192. What is Cascade and Restrict when we use DROP table in SQL SERVER ?

When we are using Drop table in SQL the syntax is simple.

Drop table table_name(CASCADE / RESTRICT)

We use cascade to drop table although it have some dependencies just like triggers,stroeprocrdure,primarykey,foreignkey it will delete first.

But if we use restrict a error message is shown on using of DROP if the table have relation Trigger,storeprocedure.

193. What is COMMIT & ROLLBACK statement in SQL ?

Commit statement helps in termination of the current transaction and do all the changes that occur in transaction persistent and this also commits all the changes to the database.COMMIT we can also use in store procedure.

ROLLBACK do the same thing just terminate the currenct transaction but one another thing is that the changes made to database are ROLLBACK to the database.

The DML component of SQL comprises four basic statements:

* SELECT to get rows from tables

* UPDATE to update the rows of tables

* DELETE to remove rows from tables

* INSERT to add new rows to tables

194. Where .NET CLR and SQL SERVER run ?

All .net realtes application and Sql Server runs in same process or we can say that on same address because there is no issue of speed because if these two process are run in different process then there may be a speed issue created one process goes fast and other slow may create the problem.

195. What are Checkpoint in SQL Server ?

When we done operation on SQL SERVER that is not commited directly to the database.All operation must be logged in to Transaction Log files after that they should be done on to the main database.CheckPoint are the point which alert Sql Server to save all the data to main database if no check point is there then log files get full we can use Checkpoint command to commit all data in the SQL SERVER.When we stop the SQL Server it will take long time because Checkpoint is also fired.

196. Can You explain integration between SQL Server 2005 and Visual Studio 2005 ?

This intergration provide wider range of development with the help of CLR for database server.Becasue CLR helps developers to get flexibility for developing database applications and also provides language interoperability just like Visual C++, Visual Basic .Net and Visual C# .Net. The CLR helps developers to get the arrays, classes and exception handling available through programming languages such as Visual C++ or Visual C# which is use in stored procedures, functions and triggers for creating database application dynamically and also provide more efficient reuse of code and faster execution of complex tasks. We particularly liked the error-checking powers of the CLR environment, which reduces run-time errors

197. What is the diffrence between SQL and Pl/Sql ?

We can get modify, Retrieve by single command or statement in SQL but PL/SQL process all SQL statements one at a time. With PL/SQL, an entire block of statements process in a single command line.sql is structured query language ,various queries are used to handle the database in a simplified manner. while pl/sql is procedural language contains various types of variable,functions and procedures and other major diffrence is Sql as the name suggest it is just structured query language wheareas PLSQL is a commbination of Programming language & SQL.

198. What is DTS in SQL Server ?

If a organization is big then it is also there that there is multiple option to store data some people are using EXCEL some are using ACCESS and some of they are using SQL SERVER and in some other format also but there a problem is arise that how to merge that data into one format there is diffrent tool are there for doing this funtion. One of product of SQL SERVER-2000 DTS helps in this problem it provides a set of tool from that tool we can customise are database acording to our need DTSRun is a command-prompt utility used to execute existing DTS packages.

199. What is the difference between UNION ALL Statement and UNION ?

The main difference between UNION ALL statement and UNION is UNION All statement is much faster than UNION,the reason behind this is that because UNION ALL statement does not look for duplicate rows, but on the other hand UNION statement does look for duplicate rows, whether or not they exist.

200. Write some disadvantage of Cursor ?

Cursor plays there row quite nicely but although there are some disadvantage of Cursor .

Because we know cursor doing roundtrip it will make network line busy and also make time consuming methods. First of all select query gernate output and after that cursor goes one by one so roundtrip happen.Another disadvange of cursor are ther are too costly because they require lot of resources and temporary storage so network is quite busy.

201. What is Log Shipping and its purpose ?

In Log Shipping the transactional log file from one server is automatically updated in backup database on the other server and in the case when one server fails the other server will have the same DB and we can use this as the DDR(disaster recovery) plan.

202. What are the null values in SQL SERVER ?

Before understand the null values we have some overview about what the value is. Value is the actual data stored in a particular field of particular record. But what is done when there is no values in the field.That value is something like .Nulls present missing information. We can also called null propagation.

217. Write a Role of Sql Server 2005 in XML Web Services?

SQL Server 2005 create a standard method for getting the database engine using SOAP via HTTP. By this method, we can send SOAP/HTTP requests to SQL Server for executing T-SQL batch statements, stored procedures, extended stored procedures, and scalar-valued user-defined functions may be with or without parameters.

218. What are the different types of Locks ?

There are three main types of locks that SQL Server

(1)Shared locks are used for operations that does not allow to change or update data, such as a SELECT statement.

(2)Update locks are used when SQL Server intends to modify a page, and later promotes the update page lock to an exclusive page lock before actually making the changes.

(3)Exclusive locks are used for the data modification operations, such as UPDATE, INSERT, or DELETE.

219. What is different in Rules and Constraints ?

Rules and Constraints are similar in functionality but there is a An little diffrence between them.Rules are used for backward compatibility . One the most exclusive diffrence is that we an bind rules to a datatypes whereas constraints are bound only to columns.So we can create our own datatype with the help of Rules and get the input according to that.

220. What is defaults in Sql Server and types of Defaults ?

Defaults are used when a field of columns is allmost common for all the rows for example in employee table all living in delhi that value of this field is common for all the row in the table if we set this field as default the value that is not fill by us automatically fills the value in the field its also work as intellisense means when user inputing d it will automatically fill the delhi . There are two types of defaults object and definations.

Object deault:-These defaults are applicable on a particular columns . These are usually deined at the time of table designing.When u set the object default field in column state this column in automatically field when u left this filed blank.

Defination default:-When we bind the datatype with default let we named this as dotnet .Then every time we create column and named its datatype as dotnet it will behave the same that we set for dotnet datatype.

221. What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?

Having Clause is basically used only with the GROUP BY function in a query. WHERE Clause is applied to each row before they are part of the GROUP BY function in a query.

222. What is Normalization ?

The logical design of the database, including the tables and the relationships between them, is the core of an optimized relational database. A good logical database design can lay the foundation for optimal database and application performance. A poor logical database design can impair the performance of the entire system.

Normalizing a logical database design involves using formal methods to separate the data into multiple, related tables. A greater number of narrow tables (with fewer columns) is characteristic of a normalized database. A few wide tables (with more columns) is characteristic of an nonnomalized database. Reasonable normalization often improves performance. When useful indexes are available, the Microsoft® SQL Server™ 2000 query optimizer is efficient at selecting rapid, efficient joins between tables.

Some of the benefits of normalization include:

·Faster sorting and index creation.

·A larger number of clustered indexes. For more information, Narrower and more compact indexes.

·Fewer indexes per table, which improves the performance of INSERT, UPDATE, and DELETE statements.

·Fewer null values and less opportunity for inconsistency, which increase database compactness.

As normalization increases, so do the number and complexity of joins required to retrieve data. Too many complex relational joins between too many tables can hinder performance. Reasonable normalization often includes few regularly executed queries that use joins involving more than four tables.

Sometimes the logical database design is already fixed and total redesign is not feasible. Even then, however, it might be possible to normalize a large table selectively into several smaller tables. If the database is accessed through stored procedures, this schema change could take place without affecting applications. If not, it might be possible to create a view that hides the schema change from the applications.

223. Can you explain what View is in SQL ?

View is just a virtual table nothing else which is based or we can say devlop with SQL SELECT query.So we can say that its a real database table (it has columns and rows just like a regular table),but one difference is that real tables store data,but views can’t. View data is generated dynamically when the view is referenced.And view can also references one or more existing database tables or other views. We can say that it is filter of database.

224. Can you tell me the difference between DELETE &TRUNCATE commands?

Delete command removes the rows from a table based on the condition that we provide with a WHERE clause. Truncate will actually remove all the rows from a table and there will be no data in the table after we run the truncate command.

225. Can you define basic element of WebServices and explain any one from them?

These are as follows SOAP, WSDL and UDDI. And I am explaining about the SOAP(Simple Object Access Protocol) it is a communication protocol it is for communication between application it is platform and language independent.It is based on XML and also help to get from Firwall.

226. Explain functioning of Web Services Protocols ?

Http-Get:- This is standard protocol that helps client to communicate with server with HTTP.When client send a request to server via HTTP request and reuired parameter are attached with the querystring.Example:-

http://www.dotnetquestion.info/dotnet/interview.aspx?id=pervej&cast=munjal and we get the value from querystring.

Request.querystring("id")

Request.querystring("cast").

Http-Post:-This is same as Http-Get but the diffrence is that in place of sending parameters onto the URL information is send with HTTP request message with some extra information which contains Parameters and their values.This Protocols is limited to sending name/value pairs.

SOAP:-The only diffrence is that its relies on the XML as compares to Http-Get,Http-Post.SOAP can send not only the name/value pairs but also some complex object also as for example datatypes,class,objects.SOAP can also uses request/reponse model as Http-Get,Http-post but it is not limited to Request/Response it can also send types of message.Because its uses XML that is pure text so firewalls not created so much problem because its easily converted in to HTML. .

227. Which one is better Remoting or WebServices ?

Remoting involves efficient communication or exchange of data when we have control on both ends of the application involved in the communication process. Web Services is open-protocol-based exchange of informaion. Web Services play there role when we need to communicataion with external organization or whicj doesnot have .NET technology.

228. How .NET and non .NET component communicate with each other when they are on different platform?

In past when we have to communicate .NET with non .NET component we are using COM component this component helps in doing this. At the moment we are using in both apps a COM component that has an intermediary Windows service running on one machine. But this component is quite old and not in use now because it will create a problem when we are using firewall. So to handle this we use Web-Services which really have a solution for Firewall.

229. Why do some web service classes derive from System.Web.WebServices while others do not ?

Those asp net Web Service classes which employ objects like Application, Session, Context, Server, and User have to derive from System.Web.WebServices. If it does not use these objects, it is not necessary to be derived from it.

230. What is WSDL ?

WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services). (Source: www.w3.org).

231. What is the standard you use to wrap up a call to a Web service ?

HTTP with SOAP.

232. What is Asp Net Web Services ?

Web services are programmable business logic components that provide access to functionality through the Internet. Standard protocols like HTTP can be used to access them. Web services are based on the Simple Object Access Protocol (SOAP), which is an application of XML. Web services are given the .asmx extension..

233. Define Protocols that helps Web Services in Asp Net?

From my point of view Web Services used three protocols for interacting with the clients.Http-Post,Http-Get,SOAP.

234. What are VSDISCO files ?

VSDISCO files are DISCO files that enable dynamic discovery of Web Services. ASP.NET links the VSDISCO to a HTTP handler that scans the host directory and subdirectories for ASMX and DISCO files and returns a dynamically generated DISCO document. A client who requests a VSDISCO file gets back what appears to be a static DISCO document.

235. What is UDDI ?

UDDI stands for Universal Description, Discovery, and Integration. It is like an "Yellow Pages" for Web Services. It is maintained by Microsoft, IBM, and Ariba, and is designed to provide detailed information regarding registered Web Services for all vendors. The UDDI can be queried for specific Web Services.

236. Is it possible to generate the source code for an ASP.NET Web service from a WSDL ?

The Wsdl.exe tool (.NET Framework SDK) can be used to generate source code for an ASP.NET web service with its WSDL link.

Example: wsdl /server http://api.google.com/GoogleSearch.wsdl.

237. Can you give an example of when it would be appropriate to use a web service as opposed to a non-serviced .NET component ?

When to Use Asp Net Web Services:

(i)Communicating through a Firewall When building a distributed application with 100s/1000s of users spread over multiple locations, there is always the problem of communicating between client and server because of firewalls and proxy servers. Exposing your middle tier components as Web Services and invoking the directly from a Windows UI is a very valid option.

(ii)Application Integration When integrating applications written in various languages and running on disparate systems. Or even applications running on the same platform that have been written by separate vendors.

(iii)Business-to-Business Integration This is an enabler for B2B intergtation which allows one to expose vital business processes to authorized supplier and customers. An example would be exposing electronic ordering and invoicing, allowing customers to send you purchase orders and suppliers to send you invoices electronically.

(iv)Software Reuse This takes place at multiple levels. Code Reuse at the Source code level or binary componet-based resuse. The limiting factor here is that you can reuse the code but not the data behind it. Webservice overcome this limitation. A scenario could be when you are building an app that aggregates the functionality of serveral other Applicatons. Each of these functions could be performed by individual apps, but there is value in perhaps combining the the multiple apps to present a unifiend view in a Portal or Intranet.

238. What are Service Oriented Architectures (SOA) ?

SOA describes an information technology architecture that enables distributed computing environments with many different types of computing platforms and applications. Web services in asp net are one of the technologies that help make SOAs possible. As a concept, SOA has been around since the 1980s, but many early IT technologies failed to achieve the goal of linking different types of applications and systems. By making early investments with .NET, Microsoft has helped provide the building blocks that today are putting many enterprise customers on the path to successfully implementing SOAs. With SOAs, companies can benefit from the unimpeded flow of information that is the hallmark of connected systems.

239. What is .NET Passport ?

.NET Passport is a Web-based service that is designed to make signing in to Web sites fast and easy. Passport enables participating sites to authenticate a user with a single set of sign-in credentials, alleviating the need for users to remember numerous passwords and user names.

240. What is .NET Remoting ?

.NET Remoting is an enabler for application communication. It is a generic system for different applications to use to communicate with one another. .NET objects are exposed to remote processes, thus allowing interprocess communication. The applications can be located on the same computer, different computers on the same network, or even computers across separate networks.

241. .NET Remoting versus Distributed COM ?

In the past interprocess communication between applications was handled through Distributed COM, or DCOM. DCOM works well and the performance is adequate when applications exist on computers of similar type on the same network. However, DCOM has its drawbacks in the Internet connected world. DCOM relies on a proprietary binary protocol that not all object models support, which hinders interoperability across platforms. In addition, have you tried to get DCOM to work through a firewall? DCOM wants to communicate over a range of ports that are typically blocked by firewalls. There are a ways to get it to work, but they either decrease the effectiveness of the firewall (why bother to even have the firewall if you open up a ton of ports on it), or require you to get a firewall that allows support for binary traffic over port 80.

.NET Remoting eliminates the difficulties of DCOM by supporting different transport protocol formats and communication protocols. This allows .NET Remoting to be adaptable to the network environment in which it is being used.

242. Can you explain what is remotable and non-remotable objects ?

The remotable objects are the objects which can be distributed accross domains, can be used with domain. The non-remotable objects are the objects which can't be distributed accross domains. In distributed system, if an object is very big, we can make it non-remotable object.

243. Security in Remoting ?

Security is of paramount importance to any distributed application. Although the .NET Remoting infrastructure does not define any security features itself, because distributed applications are managed code they have full access to all of the .NET security features. In addition, the HTTP channel, when used with IIS, allows you to take full advantage of the authentication and authorization features that are available to Web based protocols. If you choose to use a protocol other than HTTP with IIS, then you have the opportunity to create your own security infrastructure.

244. Advantage of Remoting over Web Services ?

.NET Remoting is a distributed objects infrastructure. It allows processes to share objects—to call methods on and access properties of objects that are hosted in different application domains within the same process, different processes executing on the same computer, on computers on an intranet, or on computers distributed over wide areas. .NET Remoting supports many different communications protocols, including the SOAP/HTTP protocol used by ASP.NET Web services. Support for other protocols makes it possible to provide much faster communications in .NET Remoting than would be possible with ASP.NET Web services. The ASP.NET programming model is tied specifically to IIS, and is limited to creating Web services that use the producer/consumer model. .NET Remoting, on the other hand, can share objects from any type of application.

The .NET Remoting system, as an integral part of the .NET Framework, supports full .NET type system fidelity. You can pass any object across the wire to a client. This is in contrast to ASP.NET, which is limited to data types that can be expressed with WSDL and XSD.

245. Some Important Notes

The dependence on assembly metadata implies that client applications must understand .NET concepts. As a result, applications that make use of .NET Remoting are not interoperable with other systems. Although it's possible to write an XML Web service using .NET Remoting, it's not practical when you consider that ASP.NET is designed specifically for that task. In most cases, in order to use .NET Remoting, both the client and the server must be .NET applications. This makes .NET Remoting a poor choice if you want non-.NET clients to access your service.

Before we get into the nuts and bolts of how Remoting works and how to write programs that take advantage of it, you need to understand some basic Remoting concepts.

246. .NET Remoting Overview ?

.NET Remoting is very flexible. You have a wide range of communications options and activation methods, as well as full control over a distributed object's lifecycle. You can choose TCP or HTTP communications protocols on any port, using text or binary formatting. The .NET Remoting infrastructure supports server activated (single call and singleton) and client activated objects. .NET Remoting gives you many opportunities to "plug in" to the system to customize lifecycle management, marshaling, serialization, messaging, and other services.

247. What do you mean by Web Part Control in asp.net ?

ASP.NET Web Parts controls are the integrated controls which helps in creation of Web sites that also help users to modify the content as well as appearance, and behavior of pages of web sites that are open in browser.

248. What is main difference between GridLayout and FormLayout ?

GridLayout helps in providing absolute positioning of every control placed on the page.It is easier to devlop page with absolute positioning because control can be placed any where according to our requirement.But FormLayout is little different only experience Web Devloper used this one reason is it is helpful for wider range browser.If there is absolute positioning we can notice that there are number of DIV tags.But in FormLayout whole work are done through the tables.

249. What is the purpose of IIS ?

We can call IIS(Internet Information Services) a powerful Web server that helps us creating highly reliable, scalable and manageable infrastructure for Web application which runs on Windows Server 2003. IIS helps development center and increase Web site and application availability while lowering system administration costs. It also runs on Windows NT/2000 platforms and also for above versions. With IIS, Microsoft includes a set of programs for building and administering Web sites, a search engine, and support for writing Web-based applications that access database. IIS also called http server since it process the http request and gets http response.

250. What you thing about the WebPortal ?

Web portal is nothing but a page that allows a user to customize his/her homepage. We can use Widgets to create that portal we have only to drag and drop widgets on the page. The user can set his Widgets on any where on the page where he has to get them. Widgets are nothing but a page area that helps particular function to response. Widgets example are address books, contact lists, RSS feeds, clocks, calendars, play lists, stock tickers, weather reports, traffic reports, dictionaries, games and another such beautiful things that we can not imagine. We can also say Web Parts in Share Point Portal. These are one of Ajax-Powered.

251. What is Sandbox in SQL server and explain permission level in Sql Server ?

Sandbox is place where we run trused program or script which is created from the third party. There are three type of Sandbox where user code run.

252. How many types of cookies are there in .NET ?

Two type of cookeies.

a) single valued eg request.cookies(”UserName”).value=”dotnetquestion”

b)Multivalued cookies. These are used in the way collections are used example

request.cookies(”CookiName”)(”UserName”)=”dotnetquestionMahesh”

request.cookies(”CookiName”)(”UserID”)=”interview″

253. When we get Error 'HTTP 502 Proxy Error' ?

We get this error when we execute ASP.NET Web pages in Visual Web Developer Web server, because the URL randomly select port number and proxy servers did not recognize the URL and return this error. To resolve this problem we have to change settings in Internet Explorer to bypass the proxy server for local addresses, so that the request is not sent to the proxy.

254. What is Finalizer in .NET define Dispose and Finalize ?

We can say that Finalizer are the methods that's helps in cleanp the code that is executed before object is garbage collected .The process is called finalization . There are two methods of finalizer Dispose and Finalize .There is little diffrenet between two of this method .

When we call Dispose method is realse all the resources hold by an object as well as all the resorces hold by the parent object.When we call Dispose method it clean managed as well as unmanaged resources.

Finalize methd also cleans resources but finalize call dispose clears only the unmanged resources because in finalization the garbase collecter clears all the object hold by managed code so finalization fails to prevent thos one of methd is used that is: GC.SuppressFinalize.

255. Define SMTPclient class in DotNet framework class libarary ?

Each classes in dotnet framework inclue some properties,method and events.These properties ,methods and events are member of a class.SMTPclient class mainly concern with sending mail.This class contain the folling member.

Properties:-

Host:-The name or IP address of email server.

Port:-Port that is use when sending mail.

Methods:-

Send:-Enables us to send email synchronously.

SendAsynchronous:-Enables us to send an email asynchronously.

Event:-

SendCompleted:-This event raised when an asynchronous send opertion completes.

256. What is late binding ?

When code interacts with an object dynamically at runtime .because our code literally doesnot care what type of object it is interacting and with the methods thats are supported by object and with the methods thats are supported by object .The type of object is not known by the IDE or compiler ,no Intellisense nor compile-time syntax checking is possible but we get unprecedented flexibilty in exchange.if we enable strict type checking by using option strict on at the top of our code modules ,then IDE and compiler will enforce early binding behaviour .By default Late binding is done.

257. Does .NET CLR and SQL SERVER run in different process ?

Dot Net CLR and all .net realtes application and Sql Server run in same process or we can say that that on the same address because there is no issue of speed because if these two process are run in different process then there may be a speed issue created one process goes fast and other slow may create the problem.

258. What is delay signing ?

Delay signing allows you to place a shared assembly in the GAC by signing the assembly with just the public key. This allows the assembly to be signed with the private key at a later stage, when the development process is complete and the component or assembly is ready to be deployed. This process enables developers to work with shared assemblies as if they were strongly named, and it secures the private key of the signature from being accessed at different stages of development.

259. Write an query to get Max,Min,Second max number from the table?

(i) select max(id) from emp

we can get the max id value from this query .

(ii) select min(id) from emp

we can get min id value fom the table emp.

(iii)select max(id) from emp where id<(select max(id) from emp)

this query is combinination of two sql query.

260. How to add attribute of a server side Button in javascript ?

In page load event just add Button1.Attribute.Add("onclick","_javascript:return function_name()");

261. Syntax related to Popup Box ?

Answer: In JavaScript we can create three kinds of popup boxes: Alert box, Confirm box, and Prompt box. Examples

Alert box: alert("sometext");

Confirm box: confirm("sometext")

Prompt box: prompt("sometext","defaultvalue")

262. Where to add Javscript Function and how ?

By pressing the button, a function will be called. The function will alert a message.

263. What is a Cookie ?

A cookie is a variable that is stored on the visitor's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With JavaScript, you can both create and retrieve cookie values. Examples of cookies: Name cookie - The first time a visitor arrives to your web page, he or she must fill in her/his name. The name is then stored in a cookie. Next time the visitor arrives at your page, he or she could get a welcome message like "Welcome John Doe!" The name is retrieved from the stored cookie Password cookie - The first time a visitor arrives to your web page, he or she must fill in a password. The password is then stored in a cookie. Next time the visitor arrives at your page, the password is retrieved from the cookie Date cookie - The first time a visitor arrives to your web page, the current date is stored in a cookie. Next time the visitor arrives at your page, he or she could get a message like "Your last visit was on Tuesday August 11, 2005!" The date is retrieved from the stored cookie.

264. How to Detect the visitor's browser and browser version ?

.

265. How to get Length of string ?

.

266. how to get any element of Webpage ?

Click to see what element I am!

.

267. Diffrence between function and StoreProcedure ?

Both functions and stored procedures can be custom defined and part of any application.Functions, on the other hand, are designed to send their output to a query or T-SQL statement. For example, User Defined Functions (UDFs) can run an executable file from SQL SELECT or an action query,while Stored Procedures (SPROC) use EXECUTE or EXEC to run. Both are instantiated using CREATE FUNCTION. stored procedures are designed to return its output to the application. A UDF returns table variables, while SPROC can't return a table variable although it can create a table. Another significant difference between them is that UDFs can't change server environment or your operating system environment, while a SPROC can. Operationally, when T-SQL encounters an error the function stops, while T-SQL will ignore an error in a SPROC and proceed to the next statement in your code (provided you've included error handling support). You'll also find that although a SPROC can be used in an XML FOR clause, a UDF cannot be.

268. ACID in transactions.

A transaction must be:

1.Atomic - it is one unit of work and does not dependent on previous and following transactions.

2.Consistent - data is either committed or roll back, no “in-between” case where something has

been updated and something hasn’t.

3.Isolated - no transaction sees the intermediate results of the current transaction).

4.Durable - the values persist if the data had been committed even if the system crashes right

after.

269. What’s the difference between a primary key and a unique key?

Both primary key and unique enforce uniqueness of the column on which they are defined.

But by default primary key creates a clustered index on the column, where are unique

creates a nonclustered index by default. Another major difference is that, primary key

doesn’t allow NULLs, but unique key allows one NULL only.

270. What is read only and its example ?

A read only member is like a constant in that it represents an unchanging value. The difference is that a readonly member

can be initialized at runtime, in a constructor as well being able to be initialized as they are declared. For example

public class MyClass

{

public readonly double PI = 3.14159;

}

Because a readonly field can be initialized either at the declaration or in a constructor, readonly fields can have

different values depending on the constructor used. A readonly field can also be used for runtime constants as in the

following example

public static readonly uint l1 = (uint)DateTime.Now.Ticks;

271. From where are custom exceptions derived from ?

SystemException and ApplicationException are both derrived from Exception.SystemException is the predefined base class for

exceptions that originate from theSystem namespace.ApplicationException is the class intended as a base for any application

specificexceptions that it is decided, need to be defined.If you want to define your own "exceptions" for your own specific

applicationthen it is considered good practice to derrive your own "exception" class fromApplicationExceptionpublic class

CustomException : ApplicationException .

272. What is SQL injection ?

SQL injection is a security vulnerability that occurs in the database layer of an application. The

vulnerability is present when user input is either incorrectly filtered for string literal escape

characters embedded in SQL statements or user input is not strongly typed and thereby unexpectedly

executed. It is in fact an instance of a more general class of vulnerabilities that can occur

whenever one programming or scripting language is embedded inside another.

273. Diffrence between Showding and overriding ?

1. Purpose :

Shadowing : Protecting against a subsequent base class modification introducing a member you have already

defined in your derived class

Overriding : Achieving polymorphism by defining a different implementation of a procedure or property with

the same calling sequence

2.Redefined element :

Shadowing : Any declared element type

Overriding : Only a procedure (Function or Sub) or property

3.Redefining element :

Shadowing : Any declared element type

Overriding : Only a procedure or property with the identical calling sequence

4.Accessibility :

Shadowing : Any accessibility

Overriding : Cannot expand the accessibility of overridden element (for example, cannot override Protected

with Public)

5.Readability and writability :

Shadowing : Any combination

Overriding : Cannot change readability or writability of overridden property

6.Keyword usage :

Shadowing : Shadows recommended in derived class;Shadows assumed neither Shadows nor Overrides specified

Overriding : Overridable required in base class; Overrides required in derived class

7.Inheritance of redefining element by classes deriving from your derived class :

Shadowing : Shadowing element inherited by further derived classes; shadowed element still hidden

Overriding : Overriding element inherited by further derived classes; overridden element still overridden

274. what is Deep Coy and Shallow copy ?

Shallow copy create a new reference to the same object.

Deep copy create a new reference to a new object.

275. Define candidate key, alternate key, composite key?

candidate key is one that can have row of a table unique. Generally a candidate key is

primary key of the table. If the table has more than one candidate key, one of them will

become the primary key, and the rest are called alternate keys.A key formed by combining

at least two or more columns is called composite key.

276. What is the different between <%# %> and <%= %> ?

The <%# %> is used for databinding where as <%= %> is used to output the result of an

expression. The expression inside <%# %> will be executed only when you call the page's or

control's DataBind method. The expression inside <%= %> will be executed and displayed as

and when it appears in the page.

277. How to change the Page Title dynamically ?

Declare protected System.Web.UI.HtmlControls.HtmlGenericControl Title1 ; //In Page_Load Title1.InnerText ="Page 1" ;

278. Difference between Triggers and Storedprocedures ?

Triggers are basically used to implement business rules.Triggers is also similar to stored

procedures.The difference is that it can be activated when data is added or edited or

deleted from a table in a database.Triggers are special kind of stored procedures that get

executed automatically when an INSERT,UPDATE or DELETE operation takes place on a table.

279. What is Machine.config File ?

As web.config file is used to configure one asp .net web application, same way Machine.config file is used

to configure application according to a particular machine. That is, configuration done in machine.config

file is affected on any application that runs on a particular machine. Usually, this file is not altered

and only web.config is used which configuring applications.

280. What is Code Refactoring?

Ans.Its a feature of Visual Web Express & Visual Studio 2005. Code Refactoring Code Refactoring enables you to

easily and systematically make changes to your code. Code Refactoring is supported everywhere that you can write

code including both code-behind and single-file ASP.NET pages. For example, you can use Code Refactoring to

automatically promote a public field to a full property.

281. What are Indexes in SQL SERVER?

Microsoft SQL Server index helps in creating the structure of table that helps in speeds retrieval of the rows in the table.

An index create a keys from one or more columns in the table. These keys are stored in a structure that allows SQL Server

to find the row or rows created with the key values quickly and efficiently.If a table doest not containeated indexes,the

data rows are not stored in any specific order.This structure is stored on heap.

There are two types of SQL Server indexes:

(1)Clustered:-

Clustered indexes helps in sorting and storeing the data rows in the table take key values as base. Because the data

rows are stored in sorted order on the clustered index key, clustered indexes more efficient for finding rows. There is

only one clustered index per table. The data rows themselves form the lowest level of the clustered index. The only time

the data rows in a table are stored in sorted order is when table contains a clustered index. If a table has no clustered

index, its data rows are stored in a heap.

(2)Nonclustered:-

Nonclustered indexes having structure that is diffrent from the data rows . The lowest rows of a nonclustered index have the

nonclustered index key values and each key value entry has pointers to the data rows containing the key value. The data rows

are not stored in order based on the nonclustered key. The pointer from an index row in a nonclustered index to a data row

is called a row locator. The structure of the row locator depends on whether the data pages are stored in a heap or are

clustered. In heap,a row locator is a pointer that point to the row. For a table with a clustered index, the row locator is

the clustered index key.

282. Define basic functions for master, msdb, tempdb databases in Sql Server ?

(1)master:-It contains system level information for a SQL Server system and also contains login accounts

and all system configuration settings. master is the database that records the existence of all other

databases, including the location of the database files.

(2) tempdb - This database holds all temporary tables and temporary stored procedures. It also fills any

other temporary storage needs such as work tables generated by SQL Server. tempdb is re-created every

time SQL Server is started so the system starts with a clean copy of the database.

(3)model - The model database is used as the template for all databases created on a system. When a

CREATE DATABASE statement is issued, the first part of the database is created by copying in the contents

of the model database, then the remainder of the new database is filled with empty pages. Because tempdb

is created every time SQL Server is started, the model database must always exist on a SQL Server system.

(4)msdb - The msdb database is used by SQL Server Agent for scheduling alerts and jobs, and recording

operators.

283. What is the difference between Dataset.clone and Dataset.copy ?

The one and the main diffrenet between these two is clone only copy the structure

but not the data on the other hand copy copies all the data and also the structure.

284. Define what the function RANK() do and how it different from ROW_NUMBER ?

The RANK() function have same as ROW_NUMBER but the diffrence is on its ouput its display

duplicate values are treated as diffrent with this

syntax:- select firstcol,secondcol,rank() over(order by secondcol) as rownumber from tablename

285. How to diplay alert on post back from javascript ?

string strScript = ""; if ((!Page.IsStartupScriptRegistered("clientScript"))) { Page.RegisterStartupScript("clientScript", strScript); }

286. How ROW_NUMBER function helps and what is its functioning ?

Row_NUMBEr functions add a column that display a number column to and correspondance column

althogh the column is not unique it takes order by clause also with it.

Syntax:- select firstcol,secondcol,row_number() over(order by secondcol) as rownumber from tablename

287. Why it is preferred not to use finalize for cleanup ?

There is problem with the finalize regards to object when we use finalize to destroy the object it will take two round to remove the objects.To understand it we will take a simple example let there are three objects obj1,obj2,obj3 we use finalize for obj2.Now when garbage collector is run first time it will only clean obj1,obj3 becuase obj2 is pushes to the finalization queue. Now when garbage collector runs second time it will take if any object is pending for finalization then it will check the finalization queue if any item it will destroy that one.

288. What are advantage and disadvantage of Hidden fields ?

Some of advantage of Hidden field as follows.

-These are quite simple to implement.

-We can work with the Web-Farm because data is cached on client side.

-One other reason is all browser support hidden field.

-Server resoucres not required.

And disadvantage are as follows

-Security reason not secure

-Performance decrease if data is too large.

-These are single valued and cannot handle havvy structure.

289. Example of SQL transactions ?

USE pubs

DECLARE @intErrorCode INT

BEGIN TRAN

UPDATE Authors

SET Phone = '415 354-9866'

WHERE au_id = '724-80-9391'

SELECT @intErrorCode = @@ERROR

IF (@intErrorCode <> 0) GOTO PROBLEM

UPDATE Publishers

SET city = 'Calcutta', country = 'India'

WHERE pub_id = '9999'

SELECT @intErrorCode = @@ERROR

IF (@intErrorCode <> 0) GOTO PROBLEM

COMMIT TRAN

PROBLEM:

IF (@intErrorCode <> 0) BEGIN

PRINT 'Unexpected error occurred!'

ROLLBACK TRAN

END