ASP.Net Interview Questions

1. What is ASP?
Active Server Pages(ASP), also known as Classic ASP, is a Microsoft’s server-side technology, which helps in creating dynamic and user-friendly Web pages.
It uses different scripting languages to create dynamic Web pages, which can be run on any type of browser.

2. What is the difference between Classic ASP and ASP.Net?
ASP is Interpreted language based on scripting languages like Jscript or VBScript.
ASP has Mixed HTML and coding logic.
Limited development and debugging tools available.
Limited OOPS support.
Limited session and application state management.
ASP.Net is supported by compiler and has compiled language support.
Separate code and design logic possible.
Variety of compilers and tools available including the Visual studio.Net.
Completely Object Oriented.
Complete session and application state management.
Full XML Support for easy data exchange.

3. What is ASP.NET?
ASP.NET is a server-side scripting technology that enables scripts (embedded in web pages) to be executed by an Internet server.
ASP.NET is a specification developed by Microsoft to create dynamic Web applications, Web sites and Web services.
It is a part of .NET Framework.
The ASP.NET compiles the Web Pages and provides much better performance than scripting languages, such as VBScript.
The Web Forms support to create powerful forms based Web pages.
ASP.NET Web server controls to create interactive Web applications with the help of Web server controls, you can easily create a Web application.

4. What is a Cookie?
Cookie is a lightweight executable program, which the server posts to client machines.
Cookies store the identity of a user at the first visit of the Web site and validate them later of the next visits for their authenticity.
The values of a cookie can be transferred between the user’s request and the server’s response.

5. 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, cannot maintained across machines in a Web farm.

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

7. What are the major built in objects in Asp.net? 
The major built in objects in Asp.net are as follows:
Application
Request
Response
Server
Session
Context
Trace

8. What is the difference between Server.Transfer and Response.Redirect?
Server.Transfer does not send any message to the browser but rather redirects the user directly from the server itself.
Response. Redirect sends message to the browser saying it to move to some different page.

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

10. What is AutoPostBack?
If you want a control to postback automatically when an event is raised, you need to set the AutoPostBack property of the control to True.

11. What is a round trip?
The trip of a Web page from the client to the server and then back to the client is known as a round trip.

12. What are the types of Cookies in Asp.net?
There are two types of Cookies available in Asp.net:
Session Cookie
Persistent Cookie

13. What is the difference between Session cookie and Persistent cookie?
Session Cookie:
Resides on the client machine for a single session until the user does not log out.
Persistent Cookie:
Resides on a user’s machine for a period specified for its expiry, such as 10 days, one month and never. The user can set this period manually.

14. Which is the parent class of the Web server control?
The System.Web.UI.Control class is the parent class for all Web server controls.

15. Which Asp.net objects encapsulate the state of the client and the browser?
The Session object encapsulates the state of the client and browser.
16. 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 the 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.

17. How can you identify that the Page is PostBack?
The Page object uses the IsPostBack property to check whether the page is posted back or not. If the page is a postback, this property is set to true.

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

19. 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 to the specific resource to the user.

20. 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.
21. What are the different ways to send data across pages in Asp.net?
The following two ways are used to send data across pages in Asp.net:
Session
Public properties

22. Where is the Viewstate information stored?
The Viewstate information is stored in the HTML hidden fields.

23. What are different types of directives in .NET?
@Page
@Control
@Import
@Implements
@Register
@Assembly
@OutputCache
@Reference

24. What is the default timeout for a cookie?
The default time duration for a cookie is 30 minutes.

25. What is the difference between HTML and Web server controls?
HTML controls are client-side controls therefore, all the validations for HTML controls are performed at the client side.
On the other hand, Web server controls are server-side controls; therefore, all the validations for Web server controls are performed at the server-side.
26. 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.

27. How do you create a permanent cookie?
Permanent cookies are available until 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 date-time. If u want the cookie which never expires set its Expires property equal to DateTime.maxValue.

28. Which method do you use to redirect the user to another page without performing a round trip to the client?
Server.Transfer
Server.Execute.

29. What are the major events in Global.Asax file?
Application_Init
Application Disposed
Application Error
Application Start
Application End
Application_BeginRequest
Application_EndRequest
Session Start
Session End
Application_AuthorizationRequest

30. What tag do you use to add a hyperlink column to the DataGrid?
< asp:HyperLinkColumn > < / asp:HyperLinkColumn >
31. How many languages .NET is supporting now?
When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. The site DotNetLanguages.Net says 44 languages are supported.

32. What is smart navigation?
The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.

33. How do you validate the controls in an ASP .NET page?
Using special validation controls that are meant for this. We have Range Validator, Email Validator

34. How do you turn off cookies for one page in your site?
Use Cookie.Discard property, Gets or sets the discard flag set by the server. When true, this property instructs the client application not to save the Cookie on the user's hard disk when a session ends.

35. Which two properties are on every validation control?
We have two common properties for every validation controls:
Control to Validate
Error Message
36. What are the event handlers that can be included in the Global.asax file?
The Global.asax file contains some of the following important event handlers:
Application_Error
Application_Start
Application_End
Session_Start
Session_End

37. What Asp.net objects encapsulate the state of the client and the browser?
The Session Object.

38. Which class is inherited when an Asp.net server control is added to a Web form?
The System.Web.UI.Webcontrols class is inherited when an Asp.net server controls is added to a web form.

39. What are the types of validation controls in Asp.net?
There are six types of validation controls in Asp.net:
Compare Validator
Custom Validator
Range Validator
Regular Expression Validator
RequiredField Validator
Validation Summary

40. Which namespace is needed to implement debug and trace?
System.Diagnostic
41. 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.

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

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

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

45. How can you display all validation messages in one control?
The ValidationSummary control displays all validation messages in one control.
46. What is the difference between a Label control and a Literal control?
The Label control’s final html code has an HTML tag; whereas the Literal control’s final html code contains only text, which is not surrounded by any HTML tag.

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

48. What is the function of Custom Validator?
It uses the customized validation code to perform client-side validation and server side validation.

49. What data type does the RangeValidator control support?
Integer
String.
Date.
Double
Currency

50. What is Role based security?
A role is a named set of principles that have the same privileges with respect to security (such as a teller or a manager). A principal can be a member of one or more roles. Therefore, applications can use role membership to determine whether a principal is authorized to perform a requested action.
51. Can we disable ViewState, If, yes how?
ViewState can be disabled by using "EnableViewState" property set to false.

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

53. What are the types of ASP Objects?
There are several types of Asp objects are:
Session Object
Application Object
Server Object
Request Object
Request Object
Response Object
Object Context
Error Object

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

55. How to Manage State in ASP.Net?
There are several ways to manage a state.
ViewState
QueryString
Cookies
Session
Application
56. What is a Literal Control?
The Literal control is used to display text on a page.
The text is programmable.
This control does not let you apply styles to its content.

57. Which namespaces are used for data access?
System.Data
System.Data.OleDB
System.Data.SQLClient

58. What is Remoting?
Remoting is a means by which one operating system process, or program, can communicate with another process. The two processes can exist on the same computer or on two computers connected by a LAN or the Internet.

59. What’s the use of “GLOBAL.ASAX” file?
It allows to execute ASP.NET application level events and setting application-level variables.

60. What is a SESSION and APPLICATION object?
Session object store information between HTTP requests for a particular user.
Session variables are used to store user-specific information whereas in application variables we can’t store user-specific information while application object is global across users.

61. What are all the types of data types available in ASP.NET?
There are two types of data types available in Asp.Net are: Framework specific data type Language-specific data type

62. What is the difference between System.String and System.StringBuilder classes?
System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

63. What is the differences between Server-side and Client-side code?
Server-side code is executed at the server side on IIS in ASP.NET framework. while client-side code is executed on the browser.

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

65. What is a formatter?
A formatter is an object that is responsible for encoding and serializing data into messages on one end, and desterilizing and decoding messages into data on the other end.
66. Which are the namespaces that are imported automatically by Visual Studio in ASP.Net?
There are 7 namespaces which are imported automatically: System System.Collections System.IO System.Web System.Web.UI System.Web.UI.HTMLControls System.Web.UI.HTMLControls

67. What is an Asp.net Web form?
Asp.net Webforms are designed to use controls and features that are almost as powerful as the ones used with Windows forms, and so they are called Web forms. The Webforms uses a server-side object model that allows you to create functional controls, which are executed on the server and are rendered as HTML on the client.

68. What is the life span of a static variable?
A static variable’s life span is till the class is in memory

69. What is the use of Smart Navigation property?
It is a feature provided by ASP.NET to prevent flickering and redrawing when the page is posted back.

70. How many namespaces are in .NET version 1.1?
124
71. What is AutoPostback?
AutoPostBack automatically posts the page back to the server when the state of the control is changed.

72. What is the difference between Web server controls and Custom User Controls in Asp.net?
The Asp.net Web server controls are objects on the Asp.net pages that run when the Web page is requested. Many Web server controls such as button and text box, are similar to the HTML controls. The Custom user controls are the controls that are defined by developers. These controls are a mixture of custom behaviour and predefined behaviour. These controls work like other Web server controls.

73. What is the main difference between Asp.net and Vb.net?
Asp.net is a web technology used for designing web forms and Vb.net is a programming language ASP.NET is a powerful technology for writing dynamic web pages. ASP.NET is a way of creating dynamic web pages while making use of the innovations present in .NET. VB.NET is a language. But ASP.NET is the Environment where we can create websites or webpages.

74. Is string a value type or a reference type?
String is a reference type. It can create a new instance every time.

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

76. What is the difference between an ADO.NET Dataset and an ADO Recordset?
A Dataset can represent an entire relational database in memory, complete with tables, relations, and views. A Dataset is designed to work without any continuing connection to the original data source. Datasets have no current record pointer You can use For Each loop to move through the data. Though the Dataset is universal, other objects in ADO.NET come in different versions for different data sources. Data in a Dataset is bulk-loaded, rather than being loaded on demand. You can store many edits in a Dataset, and write them to the original data source in a single operation.

77. What are the validation controls?
A set of server controls included with ASP.NET that test user input in HTML and Web server controls for programmer-defined requirements. Validation controls perform input checking in server code. If the user is working with a browser that supports DHTML, the validation controls can also perform validation using client script.

78. What is the difference between “Web.config” and “Machine.Config”?
“Web.config” files apply settings to each web application. While “Machine.config” file apply settings to all ASP.NET applications.

79. What is event bubbling?
Server controls like Data Grid, Data List, and Repeater can have other child controls inside them. Example Data Grid can have combo box inside the data grid. These child controls do not raise their events by themselves, rather they pass the event to the container parent (which can be a data grid, data list, repeater), which passed to the page as “ItemCommand” event. As the child control send events to parent it is termed as event bubbling.

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

81.What are the various security methods which IIS Provides apart from .NET?
The various security methods which IIS provides are:
Authentication Modes.
IP Address and Domain Name Restriction.
DNS Lookups DNS Lookups.
Though the Dataset is universal, other objects in ADO.NET come in different versions for different data sources.
The Network ID and Subnet Mask.
SSL.

82.What are Master Pages in ASP.NET?
ASP.NET master pages allow you to create a consistent layout for the pages in your application. A single master page defines the look and feels and standard behaviour that you want for all the pages in your application. You can then create individual content pages that contain the content you want to display. When users request the content pages, they merge with the master page to produce output that combines the layout of the master page with the content from the content page.

83.What are the advantages of ASP.Net?
ASP.NET makes development simpler and easier to maintain with an event-driven, server-side programming model.
ASP.NET offers built-in security features through windows authentication or other authentication methods.
Content and program logic are separated which reduces the inconveniences of program maintenance.
Built-in caching features.

84.What is event bubbling?
Server controls like Data Grid, Data List, and Repeater can have other child controls inside them. Example Data Grid can have combo box inside the data grid. These child controls do not raise their events by themselves, rather they pass the event to the container parent (which can be a data grid, data list, repeater), which passed to the page as “ItemCommand” event. As the child control send events to parent it is termed as event bubbling.

85.What is WSDL?
WSDL stands for Web Services Description Language is an XML-based language for describing Web services and how to access them.
WSDL is used to describe Web services.

86.How information about the user’s locale can be accessed?
The information regarding a user’s locale can be accessed by using the System.Web.UI.Page.Culture property.

87.What is the difference between JavaScript and VBScript?
JavaScript:
JavaScript is a client-side scripting language.
JavaScript is used to create interactive web applications supported by the Netscape browser.
JavaScript is simple to use, lightweight, and dynamic. Developers can easily embed code functionality for interactive applications inside a web page.
JavaScript is case sensitive and it will be run on client-side.
VBScript:
VBScript is a server-side scripting language.
VBScript is not case sensitive and it will be run on the server-side.

88.What is a web server?
A web server delivers requested web pages to users who enter the URL in a web browser. Every computer on the Internet that contains a web site must have a web server program.

89.What file extension does ASP.NET use for Web Services?
ASP.NET uses the .asmx extension for Web Service files.
 
90.What is the base class of .net?
System.object

91.What are the standard event handler parameters for ASP.NET pages?
The standard parameter list is (Sender as Object, e As EventArgs).

92.What is State management?
State Management is used to store information requests. The state management is used to trace the information or data that affect the state of the applications.

93.What are three programmatic improvements of ASP.NET over ASP?
Ease of deployment
Improved session state
The use of code declaration blocks

94.Write three common properties of all validation controls?
Three common properties of all validation control are as
Control to Validate – Provides control to validate.
ErrorMessage– Displays an error message.
IsValid– Specifies if the control’s validation has succeeded or not.
Text – Displays a text for validation control before validation.

95.Which property can be used to make a control post immediately to the server upon an event?
AutoPostBack

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

97.How can you identify that the page is Postback?
The page object uses the IsPostBack property to check whether the page is posted back or not. If the page is a postback, this property is set to true.

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

99.How do you identify a Master Page?
The master page is identified by a special @ Master directive that replaces the @ Page directive that is used for ordinary .aspx pages.

100.Explain what a diff gram is and a good use for one?
The DiffGram is one of the two XML formats that you can use to render Dataset object contents to XML. For reading database data to an XML file to be sent to a Web Service.
101. What are the different types of Validation Controls?
There are six types of validation controls available:
RequiredFieldValidator
RangeValidator
RegularExpressionValidator
CompareValidator
CustomValidator
ValidationSummary

102. 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 a project in which the controls are used.

103. What namespaces are necessary to create a localized application?
System.Globalization
System.Resources

104. What namespace do the ASP.NET Page and LiteralControl classes belong to?
System.Web.UI

105. What is the lifespan for items stored in ViewState?
Items stored in a ViewState exist for the life of the current page, including the postbacks on the same page.
106. What is Side-by-Side Execution?
The CLR allows any versions of the same-shared DLL (shared assembly) to execute at the same time, on the same system, and even in the same process. This concept is known as side-by-side execution.

107. How to view an assembly?
We can use the tool "ildasm.exe" known as "Assembly Disassembler" to view the assembly.

108. Which are the namespaces that are imported automatically by Visual Studio in ASP.Net?
There are 7 namespaces which are imported automatically.
System
System.Collections
System.IO
System.web
System.web.UI
System.web.UI.HTMLControls
System.web.UI.WebControls.

109. What are the layouts of ASP.NET Pages?
GridLayout
FlowLayout
GridLayout positions the form object on absolute x and y coordinates of the screen.
FlowLayout positions the form objects relative to each other.

110. What is a multilingual Website?
A multilingual Website serves content in many languages. It contains multiple copies for its content and other resources, such as date and time, in different languages.
111. What is a Namespace? What is the use of a namespace?
Namespaces are logical grouping of classes and other types in a hierarchical structure.
Namespaces are useful to avoid collision or ambiguity among the classes and type names.
Another use of the namespace is to arrange a group of classes for a specific purpose.

112.What’s the difference between Codebehind="MyCode.aspx.cs" and Src="MyCode.aspx.cs"?
Visual Studio uses the Codebehind attribute to distinguish the page source or programming logic from the design. Also, the src attribute will make the page compile on every request. That is the page will not be compiled in advance and stored in the bin as a dll instead it will be compiled at run time.

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

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

115. What is the difference between Value Types and Reference Types?
Value Types uses Stack to store the data.
Whereas Reference type uses the Heap to store the data.
116. 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 data which includes connections, Session States, Error Handling, Security etc.

117. 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 the advantage of speed but the disadvantage of stability because if it crashes it takes the client application also with it.
Outproc is one which works outside the client’s memory thus giving stability to the client, but we have to compromise a bit on speed.

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

119. Which control would you use if you needed to make sure the values in two different controls matched?
CompareValidator is used to ensure that two fields are identical.

120. What is the difference between HTTP-Post and HTTP-Get?
The GET method creates a query string and appends it to the script's URL on the server that handles the request.
The POST method creates a name/value pairs that are passed in the body of the HTTP request message.


0 comments:

Post a Comment

Please do not enter any spam link in the message box.