Jun 29

ASP.NET Interview Questions And Answers Part-2

ASP.NET Interview Questions And Answers

What are the types of ASP Objects?
There are various types of Asp objects
• Session Object
• Application Object
• Server Object
• Request Object
• Request Object
• Response Object
• Object Context
• Error Object
What is Difference between Namespace and Assembly?
Namespace is a logical design-time naming convenience, whereas an assembly establishes the name scope for types at run time.

What is the difference between ASP Session and ASP.NET Session?
Asp.net session supports cookie less session & it can span across multiple servers.

What tools can I use to develop .NET applications?
There are a number of tools, described here in ascending order of cost:
The .NET Framework SDK is free and includes command-line compilers for C++, C#, and VB.NET and various other utilities to aid development. • ASP.NET Web Matrix is a free ASP.NET development environment from Microsoft. As well as a GUI development environment, the download includes a simple web server that can be used instead of IIS to host ASP.NET apps. This opens up ASP.NET development to users of Windows XP Home Edition, which cannot run IIS.

What are remotable objects in .NET Remoting?
Remotable objects are the objects that can be marshaled across the application domains. You can marshal by value, where a deep copy of the object is created and then passed to the receiver. You can also marshal by reference, where just a reference to an existing object is passed.

What is the difference between ASP Session State and ASP.Net Session State?
ASP session state relies on cookies, Serialize all requests from a client, does not survive process shutdown, Can not maintained across machines in a Web farm.

What is the difference between ASP Session and ASP.NET Session?
Asp.net session supports cookie less session & it can span across multiple servers.

What is reflection?
All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection.
The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly.

What is the difference between Server.Transfer and response.Redirect?
The Server.Transfer () method stops the current page from executing, and runs the content on the specified page, when the execution is complete the control is passed back to the calling page.
While the Response.Redirect () method transfers the control on the specified page and the control is never passed back to calling page after execution.

What are some ways to manage state in an ASP.Net application?
Session objects, Application objects, ViewState, cookies, hidden form fields.

In which event are the controls fully loaded?
Page_load event guarantees that all controls are fully loaded. Controls are also accessed.
In Page_Init events but you will see that viewstate is not fully loaded during this event.

Can we disable ViewState, If, yes how?
ViewState can be disabled by using “EnableViewState” property set to false.

Can you give an example of what might be best suited to place in the Application_Start and Session_Start subroutines?
All the global declarations or the variables used commonly across the application can be deployed under Application_Start. All the user specific tasks or declarations can be dealt in the Session_Start subroutine.

What is an assembly?
Assemblies are the building blocks of the .NET framework. They are the logical grouping of the functionality in a physical file.

What are different types of Assemblies?
Single file and multi file assembly.
Assemblies can be static or dynamic.
Private assemblies and shared assemblies.

Which method do you invoke on the DataAdapter control to load your generated dataset with data?
DataAdapter’s fill () method is used to fill load the data in dataset.

Which template is to be provided in the Repeater control in order to display a data?

What are the advantages of an assembly?
Increased performance.
Better code management and encapsulation.
It also introduces the n-tier concepts and business logic.

What is an ArrayList?
The ArrayList object is a collection of items containing a single data type values.

What is the use of @ Register directives?
@Register directive informs the compiler of any custom server control added to the page.

Define RequiredFieldValidator?
It checks whether the control have any value. It’s used when you want the control should not be empty.

What are the different types of Session state management options available with ASP.NET?
ASP.NET provides In-Process and Out-of-Process state management. In-Process stores the session in memory on the web server. Out-of-Process Session state management stores data in an external data source. The external data source may be either a SQL Server or a State Server service. Out-of-Process state management requires that all objects stored in session are serializable.

What are the difference between const and readonly?
• A const can not be static, while readonly can be static.
• A const need to be declared and initialized at declaration only, while a readonly can be initialized at declaration or by the code in the constructor.
• A const’s value is evaluated at design time, while a readonly’s value is evaluated at runtime.

How do you turn off cookies in one page of your asp.net application?
We may not use them at the max, However to allow the cookies or not, is client side functionality.

What’s the difference between Response.Write () and Response.Output.Write()?
Response.Outout.Write allows us to write the formatted out put.

What is a PostBack?
The process in which a Web page sends data back to the same page on the server.

What’s a bubbled event?
When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their event handlers, allowing the main DataGrid event handler to take care of its constituents.

What is the difference between static or dynamic assemblies?
Assemblies can be static or dynamic. Static assemblies can include .NET Framework types (interfaces and classes), as well as resources for the assembly (bitmaps, JPEG files, resource files, and so on). Static assemblies are stored on disk in portable executable (PE) files.
Dynamic assemblies, which are run directly from memory and are not saved to disk before execution. You can save dynamic assemblies to disk after they have executed.

What are the difference between Structure and Class?
• Structures are value type and Classes are reference type
• Structures can not have constructor or destructors.
• Classes can have both constructor and destructors.
• Structures do not support Inheritance, while Classes support Inheritance.

What is the differences between dataset.clone and dataset.copy?
Dataset.clone copies just the structure of dataset (including all the datatables, schemas, relations and constraints.); however it doesn’t copy the data.
Dataset.copy, copies both the dataset structure and the data.

What is the difference between Custom Control and User Control?
Custom Controls are compiled code (Dlls), easier to use, difficult to create, and can be placed in toolbox. Drag and Drop controls. Attributes can be set visually at design time. Can be used by Multiple Applications (If Shared Dlls), Even if Private can copy to bin directory of web application add reference and use. Normally designed to provide common functionality independent of consuming Application. User Controls are similar to those of ASP include files, easy to create, can not be placed in the toolbox and dragged – dropped from it. A User Control is shared among the single application files.

What is the difference between inline and code behind?
Inline code written along with the html and design blocks in an .aspx page.
Code-behind is code written in a separate file (.cs or .vb) and referenced by the .aspx page.

What does WSDL stand for? What does it do?
(Web Services Description Language). It describes the interfaces and other information of a web service.

Which WebForm Validator control would you use if you needed to make sure the values in two different WebForm controls matched?
CompareValidator Control

What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control?
You must set the DataSource property and call the DataBind method

Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the
page loading process.
inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension),the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.

What is Marshalling?
Marshaling is a process of making an object in one process (the server) available to another process (the client). There are two ways to achieve the marshalling.
1. Marshal by value
2. Marshal by reference.

What is a Static class?
Static class is a class which can be used or accessed without creating an instance of the class.

What is boxing and unboxing?
Implicit conversion of value type to reference type of a variable is known as BOXING, for example integer to object type conversion. Conversion of reference type variable back to value type is called as UnBoxing.

What is serialization?
Serialization is the process of converting an object into a stream of bytes.
Deserialization is the opposite process of creating an object from a stream of bytes. Serialization / Deserialization is mostly used to transport objects.

What is difference between constants, readonly and, static?
Constants: The value can’t be changed.
Read-only: The value will be initialized only once from the constructor of the class.
Static: Value can be initialized once.

What is difference between abstract classes and interfaces?
Abstract classes can have concrete methods while interfaces have no methods implemented.
Interfaces do not come in inheriting chain, while abstract classes come in inheritance.

What is the difference between Server-side scripting and Client-side scripting?
Server side scripting means that all the script will be executed by the server and interpreted as needed. ASP doesn’t have some of the functionality like sockets, uploading, etc.
Client side scripting means that the script will be executed immediately in the browser such as form field validation, clock, email validation, etc. Client side scripting is usually done in VBScript or JavaScript.

How do you create a permanent cookie?
Permanent cookies are available until a specified expiration date, and are stored on the hard disk.So Set the ‘Expires’ property any value greater than DataTime.MinValue with respect to the current datetime. If u want the cookie which never expires set its Expires property equal to DateTime.maxValue.

Which method do you use to redirect the user to another page without performing a round trip to the client?

What tag do you use to add a hyperlink column to the DataGrid?
< asp:HyperLinkColumn > < / asp:HyperLinkColumn >

What is web.config file?
Web.config file is the configuration file for the Asp.net web application. There is one web.config file for one asp.net application which configures the particular application. Web.config file is written in XML with specific tags having specific meanings.It includes databa which includes connections,Session States,Error Handling,Security etc.

What is the difference between in-proc and out-of-proc?
An Inproc is one which runs in the same process area as that of the client giving tha advantage of speed but the disadvantage of stability becoz if it crashes it takes the client application also with it. Outproc is one which works outside the clients memory thus giving stability to the client, but we have to compromise a bit on speed.

What is a PostBack?
The process in which a Web page sends data back to the same page on the server.

What is Authentication and Authorization?
Authentication is the process of identifying users. Authentication is identifying/validating the user against the credentials (username and password) and Authorization performs after authentication.
Authorization is the process of granting access to those users based on identity. Authorization allowing access of specific resource to user.

What are the types of Authentication?
There are 3 types of Authentication. Windows, Forms and Passport Authentication.
• Windows authentication uses the security features integrated into the Windows NT and Windows XP operating systems to authenticate and authorize Web application users.
• Forms authentication allows you to create your own list/database of users and validate the identity of those users when they visit your Web site.
• Passport authentication uses the Microsoft centralized authentication provider to identify users. Passport provides a way to for users to use a single identity across multiple Web applications. To use Passport authentication in your Web application, you must install the Passport SDK.
What are the different types of Validation Controls?
There are six types of validation controls available :
• RequiredFieldValidator
• RangeValidator
• RegularExpressionValidator
• CompareValidator
• CustomValidator
• ValidationSummary
What is the Web User Control?
Combines existing Server and/or HTML controls by using VS.Net to create functional units that encapsulate some aspects of UI. Resides in Content Files, which must be included in project in which the controls are used.

What namespaces are necessary to create a localized application?

How to Manage State in ASP.Net?
There are several ways to manage a state.
• ViewState
• QueryString
• Cookies
• Session
• Application
What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?
Server.Transfer transfers excution directly to another page. Response.Redirect sends a response to the client and directs the client (the browser) to load the new page (it causes a roundtrip). If you don’t need to execute code on the client, Transfer is more efficient

How to Create a Cookie?
Cookie are one of several ways to store data about web site visitors during the time when web server and browser are not connected. Common use of cookies is to remember users between visits. Practically, cookie is a small text file sent by web server and saved by web browser on client machine.
The“Response.Cookies” command is used to create cookies.

What does the “EnableViewState” property do? Why would I want it on or off?
It allows page objects to save their state in a Base64 encoded string in the page HTML. One should only have it enabled when needed because it adds to the page size and can get fairly large for complex pages with many controls.

What is the difference between ASP Session State and ASP.Net Session State?
ASP session state relies on cookies, Serialize all requests from a client, does not survive process shutdown, Can not maintained across machines in a Web farm.

What is ViewState?
ViewState is a .Net mechanism to store the posted data among post backs. ViewState allows the state of objects to be stored in a hidden field on the page, saved on client side and transported back to server whenever required.

How can I maintain Session state in a Web Farm or Web Garden?
Use a State Server or SQL Server to store the session state.

What is datagrid?
The DataGrid Web server control is a powerful tool for displaying information from a data source. It is easy to use; you can display editable data in a professional-looking grid by setting only a few properties. At the same time, the grid has a sophisticated object model that provides you with great flexibility in how you display the data.

How do you hide the columns?
One way to have columns appear dynamically is to create them at design time, and then to hide or show them as needed. You can do this by setting a column’s “Visible” property.

What data type does the RangeValidator control support?
Integer, String and Date.

What is cookies?
Cookies are small pieces of text, stored on the client’s computer to be used only by the website setting the cookies. This allows webapplications to save information for the user, and then re-use it on each page if needed.

How many classes can a single .NET DLL contain?
It can contain many classes.

What methods are fired during the page load?
Init() – when the page is instantiated.
Load() – when the page is loaded into server memory.
PreRender() – the brief moment before the page is displayed to the user as HTML.
Unload() – when page finishes loading.

What is the difference between Value Types and Reference Types?
Value Types uses Stack to store the data.
where as Reference type uses the Heap to store the data.

What is difference between abstract classes and interfaces?
Abstract classes can have concrete methods while interfaces have no methods implemented. Interfaces do not come in inheriting chain, while abstract classes come in inheritance.

What is GAC or Global Assembly Cache?
Global Assembly Cache (GAC) is a common place to share the .NET assemblies across many applications. GAC caches all strong named assembly references within it. All System assemblies that come with the .NET framework reside in the GAC.

What is a HashTable?
The Hashtable object contains items in key/value pairs. The keys are used as indexes, and very quick searches can be made for values by searching through their keys.

What is CAS or Code Access Security?
Code Access Security – CAS is the part of the .NET security model that determines whether or not a piece of code is allowed to run, and what resources it can use when it is running.

What is the Composite Custom Control?
Combination of existing HTML and Server Controls.

What is RangeValidator?
RangeValidator – checks whether a value falls within a given range of number, date or string.

What base class do all Web Forms inherit from?
System.web.UI.Page class

What is the difference between String and StringBuilder classes?
• String is immutable.
• StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.
What is ValidationSummary?
ValidationSummary – It show a summary of errors raised by each control on the page on a specific spot or in a message box.

Hi Chandra,

Permanent link to this article: http://zappmania.in/2013/06/29/asp-net-interview-questions-and-answers-part-2.htm

Leave a Reply

Your email address will not be published.