.NET Interview Questions – Part 3

1.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.A demonstration of extender classes can be found over here.

2.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

3.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.
Source: Exforsys.

4.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.

5.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.

6.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.

7.Can you use multiple inheritance in .NET?

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

8.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.

9.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).Compare C# and VB.NET.

10.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.

11.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.

12.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.

13.What is business logic?

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

14.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.

15.What is a control?

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

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

The differences can be studied over here.

17.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.
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.

18.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).

19.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.

20.What is instrumentation?

It is the ability to monitor an application so that information about the application’s progress, performance and status can be captured and reported.

21.What is code review?

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

22.What is logging?

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

23.What are mock-ups?

Mock-ups are a set of designs in the form of screens, diagrams, snapshots etc., that helps verify the design and acquire feedback about the application’s requirements and use cases, at an early stage of the design process.

24.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.

25.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.

26.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

27.What is BLOB ?

A BLOB (binary large object) is a large item such as an image or an exe  represented in binary form.

28.What is ClickOnce?

ClickOnce is a new deployment technology that allows you to create and publish self-updating applications that can be installed and run with minimal user interaction.

29.What is object role modeling (ORM) ?

It is a logical model for designing and querying database models. There are various ORM tools in the market like CaseTalk, Microsoft Visio for Enterprise Architects, Infagon etc.

30.What is a private assembly?

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

31.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.

32.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.

33.What are design patterns?

Design patterns are common solutions to common design problems.

34.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.

35.What is a flat file?

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

36.Where do custom controls reside?

In the global assembly cache (GAC).

37.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).

38.What is a binary formatter?

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

39.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.

40.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.

41.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.

42.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.

43.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.

44.What is globalization?

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

45.What is localization?

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

46.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”.

47.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.

48.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.

49.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.

50.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.

51.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.

52.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.

53.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.

54.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.

55.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.

56.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.

57.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.

58.What is a dynamic assembly?

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

59.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.

60.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.

61.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.

62.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.

63.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.
– 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:WINDOWSassembly OR C:WINNTassembly) (shfusion.dll tool)
·         gacutil -i abc.dll

64.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.

65.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.

66.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.

67.What is XHTML? Are ASP.NET Pages compliant with XHTML?

In simple words, XHTML is a stricter and cleaner version of HTML. XHTML stands for EXtensible Hypertext Markup Language and is a W3C Recommendation.
Yes, ASP.NET 2.0 Pages are XHTML compliant. However the freedom has been given to the user to include the appropriate document type declaration.
More info can be found at http://msdn2.microsoft.com/en-us/library/exc57y7e.aspx

68.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.

69.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.

70.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.

71.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.

72.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.

73.How do you secure your connection string information?

By using the Protected Configuration feature.

74.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.

75.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.

76.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.

77.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.

78.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.

79.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.

80.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.

81.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.

82.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.

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

By specifying the theme in the web.config file.
Eg: <configuration>
<pages theme=”BlueMoon” />

84.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.

85.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.

86.Do webservices support data reader?

No. However it does support a dataset.

87.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.

88.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.

89.Can you programmatically access IIS configuration settings?

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

90.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.

91.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.

92.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.

93.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.

94.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.

95.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.

96.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.

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

Page class in the System.Web.UI namespace.

98.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.

99.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.

100.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.
There is an excellent article by Peter Bromberg to understand Viewstate in depth.

101.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.

102.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.

103.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.

104.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.

105.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.

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

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

107.Where do you store your connection string information?

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

108.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.NetFrameworkVersionCONFIG.
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.

109.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” %>

110.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.

111.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.

112.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:
<asp:button runat=”server” BackColor=”blue” BorderColor=”Gray” Font-Bold =”true” ForeColor=”white”/>
Defines a skin that will be applied to all buttons throughout to give it a consistent look and feel.

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

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

114.What is a User Control?

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

115.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

116.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.

117.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.

118.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.

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


120.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.



This site uses Akismet to reduce spam. Learn how your comment data is processed.