Thursday, March 24, 2011

ASP.NET Interview Questions

1. What is ASP.NET?

ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to build dynamic web sites, web applications and web services. It was first released in January 2002 with version 1.0 of the .NET Framework, and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime (CLR), allowing programmers to write ASP.NET code using any supported .NET language. The ASP.NET SOAP extension framework allows ASP.NET components to process SOAP messages.
2. What are the advantages of using ASP.NET?
• Web application exists in compiled form on the server so the execution speed is faster as compared to the interpreted scripts.
• ASP.NET makes development simpler and easier to maintain with an event-driven, server-side programming model.
• Being part of .Framework, it has access to all the features of .Net Framework.
• Content and program logic are separated which reduces the inconveniences of program maintenance.
• ASP.NET makes for easy deployment. There is no need to register components because the configuration information is built-in.
• To develop program logic, a developer can choose to write their code in more than 25 .Net languages including VB.Net, C#, JScript.Net etc.
• Introduction of view state helps in maintaining state of the controls automatically between the postbacks events.
• ASP.NET offers built-in security features through windows authentication or other authentication methods.
• Integrated with ADO.NET.
• Built-in caching features.
3. Explain the ASP.NET page lifecycle
Life cycle stages:
Start page:  Properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostback property.
Initialization: Controls on the page are available and each control's UniqueId property is set. A master page and themes are also applied to the page if applicable.
Load:  If the current request is a postback, control properties are loaded with information recovered from view state and control state
Postback:  Event handling if the current request is a postback, control properties are loaded with information recovered from view state and control state
Rendering:  The page calls the Render method for each control, providing a text writer that writes its output to the OutputStream object of the page's Response property.
Unload: The Unload event is raised after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and cleanup is performed.

 4. What happens in Preinit event?

Raised after the start stage is complete and before the initialization stage begins. This event can be  used for doing following:
·        Check the IsPostBack property to determine whether this is the first time the page is being   processed. The IsCallback and IsCrossPagePostBack properties have also been set at this time.
·         Create or re-create dynamic controls.
·         Set a master page dynamically.
·         Set the Theme property dynamically.
·         Read or set profile property values.

.NET Objective Questions

Which of the following is not an objective of .NET Framework?
  1. To provide a consistent object-oriented programming environment whether object code is stored and executed locally, executed locally but Internet-distributed, or executed remotely.
  2. To provide a code-execution environment that minimizes software deployment and versioning conflicts.
  3. To provide a code-execution environment that promotes safe execution of code, including code created by an unknown or semi-trusted third party.
  4. To provide a code-execution environment that eliminates the performance problems of scripted or interpreted environments.
  5. None of these
You cannot use .NET Framework to develop
  1. Console applications.
  2. Windows GUI applications (Windows Forms).
  3. ASP.NET applications.
  4. Applets.

Overview Of .NET

The .NET Framework (pronounced dot net) is a software framework for Microsoft Windows operating systems. It includes a large library, and it supports several programming languages which allows language interoperability (each language can use code written in other languages). The .NET library is available to all the programming languages that .NET supports.
The .NET Framework is an integral Windows component that supports building and running the next generation of applications and XML Web services. The .NET Framework is designed to fulfill the following objectives:
  • To provide a consistent object-oriented programming environment whether object code is stored and executed locally, executed locally but Internet-distributed, or executed remotely.
  • To provide a code-execution environment that minimizes software deployment and versioning conflicts.
  • To provide a code-execution environment that promotes safe execution of code, including code created by an unknown or semi-trusted third party.
  • To provide a code-execution environment that eliminates the performance problems of scripted or interpreted environments.
  • To make the developer experience consistent across widely varying types of applications, such as Windows-based applications and Web-based applications.
  • To build all communication on industry standards to ensure that code based on the .NET Framework can integrate with any other code.
.NET framework consists of three main parts. It has been divided to three parts just to make sure to keep the abstraction it requires when it comes to understanding and development. Let’s try to understand each of these parts of the framework in detail.

Common Language Runtime
Have you ever heard of JVM (Java Virtual Machine)? Do you know what it exactly does? If you know the answer, then it is quite easy for you to understand what Common Language Runtime (CLR) is.

Common Language Runtime has two basic roles to play in both development time experience and component’s runtime.
The common language runtime manages memory, thread execution, code execution, code safety verification, compilation, and other system services. These features are intrinsic to the managed code that runs on the common language runtime.
The CLR allows programmers to ignore many details of the specific CPU that will execute the program. It also provides other important services, including the following:

·         Memory management
·         Thread management
·         Exception handling
·         Garbage collection
·         Security
Unified Programming Classes
Have you ever dreamt of inheriting one language’s classes in to another? How wonderful will it be when writing parts of the same application in different languages?
Unified programming classes are the answer for this thrilling question. When it comes to C++, programmers access Microsoft Foundation classes to write applications. In Java, the Windows Foundation classes are accessed by programmers when writing applications. .NET framework has integrated these two categories to one set of APIs, so the library has become language independent.
Therefore, .NET framework enables cross language error handling, debugging, and inheritance.
In addition to that, the .NET framework provides a set of libraries that are object oriented, hierarchical, and extensible.

Client and Server Application Development
Client applications are the closest to a traditional style of application in Windows-based programming. These are the types of applications that display windows or forms on the desktop, enabling a user to perform a task. Client applications include applications such as word processors and spreadsheets, as well as custom business applications such as data-entry tools, reporting tools, and so on.
reporting tools, and so on.

Server-side applications in the managed world are implemented through runtime hosts. Unmanaged applications host the common language runtime, which allows your custom managed code to control the behavior of the server. This model provides you with all the features of the common language runtime and class library while gaining the performance and scalability of the host server.
ASP.NET is the hosting environment that enables developers to use the .NET Framework to target Web-based applications.