asp.net interview questions answers
Question & Answers
ASP NET interview questions answers help job seekers and freshers to have basic and advance knowledge of C# language and Dot Net framework. Experienced also can take the advantage of ASP NET interview questions answers post. I got the feedback from many C# developers that they found ASP NET interview questions answers post very helpful for succeeding in freelancers.com and upwork.com exam ASP NET test. ASP NET interview questions answers have been designed to help you understand the basics and advance commands.
In asp net tutorial almost all topics like asp net page cycle, Session and cookies, User Control, Themes, Styles, application variables ect have been covered.
What is ASP.NET?
ASP.NET is a development platform designed by Microsoft for creating dynamic web applications,web sites and web services being a part of .net Framework it supports Dot Net compatible languages like Visual Basic, C# and J#. Using the web server control, which maintain their state in case of round trip, you can create interactive web applications.
1. List Event Life cycle of ASP.NET.
ASP.NET page goes through a life cycle in which it performs a series of events or methods. Following are those events or methods.
- PreInit –This is the very first event which occurs, at this point you can change master page theme dynamically and also create user control and change CSS dynamically.
- Init – All control on page are initialized.
- Init Complete - Page is initialized and the process has been completed.
- PreLoad- Occurs before the loading of the page is completed.
- Load–This event indicates that all control and their properties have been loaded fully.
- LoadComplete- This informs that the page has been loaded in the memory.
- PreRender – PreRender is a opportunity for developer for changing the content of pages or other changes. It first fires for the page and then for all the controls.
- PreRenderComplete - Indicates that the PreRender phase is completed.
- SaveStateComplete- In this event, the current state of the control is completely saved to the ViewState.
- Unload–It is useful for closing database connection and other native connection.
2. Define the ViewState.
View state is a method used by ASP.NET page for maintaining page and control values between round trips. The current state of page and controls are serialized into base64-encoded string.
3. Define EnableViewState property.
It enables the view state property on page. if enabled then View state is a method used by ASP.NET page for maintaining page and control values between round trips. The current state of page and controls are serialized into base64-encoded string.
4. Define AutoPostBack in ASP.NET.
Autopostback property is a boolean property by default it is false. If we set autopostback property to true of any control then after processing on any control a request (postback) is send to the server.
5. How to disable AutoPostBack of Control?
Change the property of control AutoPostBack=false;
6. Which base class does the web form inherit from?
7. What are ASP.NET Page Directives?
Asp.Net page directives are instruction for compiler to process the web page according to directives included in page. For example to include additional resources like user control you have to declare it in directives.
Syntex: <%@ directive_name attribute=value [attribute=value] %>
List of Directives
- @Page : Attributes for page can be applied using this directive.
- Example: <%@Page Language="C#" AutoEventWIreup="false" CodeFile="Default.aspx.cs" Inherits="_Default"%>
- @Control : To use the usercontrol and its properties this directive is used.
- <%@Control Language="C#" Explicit="True" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>
- @Import : To include or import namespace use this directive.
- <%@Import Namespace="System.Data"%>
- @Implements : To implement an interface use this directive.
- <%@Implements Interface="System.Web.UI.IValidator"%>
- @Register : To use the User control on page, user control must be registered on page so that current web page can use it.
- <%@ Register TagPrefix="UCTag" Namespace="UCName.UCNameSpace" Assembly="UCAssembly"%>
- @Assembly : To access the members of an external assembly it must be registered using this directive.
- <%@Assembly src="YourAssembly.cs">
- @Reference:The Reference directive indicates that another page or user control should be compiled and linked to the current page.
- <%@ Reference Page ="somepage.aspx" %>
8. List the Validation Controls in ASP.NET.
ASP.NET validation controls prevent user to input invalid and garbage data in interactive web pages because ASP.NET validation controls shows warning if given data does not match with criteria given in validation control.
ASP.NET provides the following validation controls:
- RequiredFieldValidator : This control ensures that the required field is not empty.
- RangeValidator: Ensures that given value is within the range specified in control i.e Range(1,100)
- CompareValidator: Compares the value with value of another control.
- RegularExpressionValidator : RegularExpressionValidator uses a pattern from regular expression for validating the input text.
- CustomValidator : You can write custom validation logic for validation of the data.
- ValidationSummary: This control displays the values of the ErrorMessage property of all validation controls that failed validation.
9. How to check that page is post back?
Using Page IsPostBack Property.
10. Define Themes.
A theme is a collection of property settings that allow you to set the appearance of of pages and controls across entire web application.
11. Define User Control.
A user control is like an unit having control, methods and properties with extension .ASCX whose methods and properties can be reused. It is embeded in ASP.NET web pages that works much like an ASP.NET Web page.
12. Define user and custom controls.
13. Where connection string information is saved?
14. Define ‘Web.config’ and ‘Machine.config’.
- Machine.Config is the part of Visual Studio. Net installation whereas ASP.Net web application project creates the web.config.
- Machine.config's settings are applicable on whole asp.net application installed on same server whereas settings in the Web.config file are applicable to that particular web application only.
- Only one machine.config file exists on a server whereas each web application has its own web.config file.
- Machine.config file is at the highest level in the configuration hierarchy whereas Web.config is called application level configuration file.
15. Define Server.Transfer and Response.Redirect.
The Response.Redirect method redirects a request to a new URL and it could be another web application while the Server.Transfer method transfer the request for another aspx page within same web application, terminates execution of the current page and starts execution of a new page using the specified URL path of the page.
16. What is a webservice?
For client and server applications that communicate over the World Wide Web’s (WWW) web services are very useful. Web services uses HyperText Transfer Protocol (HTTP).
17. Define ASP.NET Session State Modes.
There are several different session state modes in ASP.NET. They provide different ways to store the session state.
- InProc mode: It is the default mode and stores the session state in the web server memory.
- StateServer mode: ASP.NET state service maintain the session state and session state is preserved If the app is restarted.
- SQLServer mode: Session state is stored in SQL database.
- Custom mode: Custom code can be written for storing the session state in custom storage.
- Off mode: Disables the session state.
18. Explain Global.asax.
Global.asax allows to write code logic, declare global variables, events which are applicable on entire application.
19. What is the lifespan for items stored in ViewState?
2o. What is App_Code folder in ASP.NET?
21. What is tracing?
22. Which method is used to force all the validation controls to run?
23. Define Response.Write() and Response.Output.Write().
24. List the event handlers that can be included in the Global.asax file.
25. What does the .WebPart file do?
26. What is the appSettings Section in the web.config file?
<add key="ConnectionString" value="server=MyServer; pwd=MyPwd; database=MyDb" />
27. Define culture.
28. Define absolute expiration and sliding-time expiration.
29. Explain client side state management system.
- View state: All the controls on ASP.NET page maintain their state within the page only.
- Control state: Control state can be persisted even it is not part of view state.
- Hidden fields: The hidden fields not visible on page can store information and can be accessed information of hidden fields during the round trip of pages.
- Cookies: Cookies are small piece of information that server creates on the browser.
- Query strings: In query strings, values are stored at the end of the URL.
30. Explain server side state management system.
- Application State: The information or variables stored in this state are available throughout entire application.
- Cache Object: Caching increases your application’s performance, scalability, and availability.
- Session State: Session object stores user-specific data between individual requests. This object is same as application object but it stores the data about particular user.
31. What are the HTML server controls in ASP.NET?
- HTML server controls are similar to the standard HTML elements like those used in HTML pages.
- They expose properties and events for programatical use.
- To make these controls programmatically accessible, we specify that the HTML controls act as a server control by adding the runat="server" attribute.
32. Various types of Cookies in ASP.NET.
- Session Cookie : It resides on client's machine for dealing one session and is alive till logs out of the session.
- Persistent Cookie : It resides on the machine of a user for a specified period. This period can be set up manually by the user.
33. What is caching in ASP.NET?
Caching is a technique of storing frequently used data/information in memory, so that, when the same data/information is needed next time, it could be directly retrieved from the memory instead of being generated by the application.
- Output Caching : Output cache keeps a copy of rendered html page to serve the next client's request for same page, thus saving time for re rendering the same page.
- Data Caching : A data source caches the data information to serve the same data request. When caching is expired then fresh data is fetched from the data source and cached.
- Object Caching : For frequent fetching of data from data bound control you can cache the data bound control this process is called object caching.
- Configuration Caching : Application wide configuration information is stored in a configuration file. Configuration caching stores the configuration information in the server memory.
34. Define App Domain Concept in ASP.NET.
An application domain is container or boundary for every .NET applications having all resource like data, code and configuration settings. Two .Net application can not access the resources of each other. Common Language Runtime (CLR) is responsible for loading the application in domain created by run time hosts.
35. What is MVC?
The Model-View-Controller (MVC) is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller.
- The Model − A set of classes(Model Data) that describes the data you are working with as well as the business logic.
- The View −Decides how the look and feel of data will appeared. It could be Html or combination html and other UI mark up languages.
- The Controller − Contains the processing logic and establish a communication between user and server.
36. List the data controls available in ASP.NET.
Data controls used to display the records in the form of reports.
- Repeater data control : This control is responsible for displaying the repeated list of the items that are bound to the control.
- Detailsview data control: This control is responsible for single record of data at a time. It supports updating, insertion or deletion of the record.
- GridView data control:This control displays the data in tabular form. It supports editing deleting and sorting of data,
- DataList data control:This control displays data as items in a list. Presentation of the data can be customized via templates.
- FormView data control:This control displays a single record of data at a time like DetailsView control and supports the editing of record.
37. Define HttpContext.Current.Items and HttpContext.Current.Session.
HttpContext.Current.Item” data is live for single HTTP request/Response where HttpContext.Current.Session data is live throughout user’s session.
38. What do you mean by a neutral culture?
39. What are Differences between ASP.NET HttpHandler and HttpModule?
- HTTP Handler: All HTTP requests are handled by HTTP Handler. It is a process which responds to HTTP request. So whenever user makes a requests HTTP handler determines the nature of request i.e if request is for a file then appropriate process the file based on the extension. You can create your own custom handlers.
- HTTP Modules: HTTP Modules are embded in a request. So all HTTP modules embded in request analysis the request. So generally http modules are used for:
- Security: A request before the request is handled for authenticating .
- Statistics and Logging: To get statistics and logging information this module can be used.
- Custom header: response is modifiable so you can add custom header information to the response.
40. What is connection pooling?
Connection pool is a container for connection instances. Very First time whenever a connection is created then a pool is created. When a new connection is created with same connection string as the first one, it reuses the same and existing connection object from the pool without creating a new one. If the connection string is different then a new connection pooling will be created, thus won't use the existing connection object. By default, we have connection pooling enabled in .Net.
41. Explain serialization and deserialization.
- Serialization is the process of converting an object into a stream of bytes.
- Deserialization is the process of creating an object from a stream of bytes.
42. Differentiate between a HyperLink control and a LinkButton control.
-A HyperLink control does not have the Click and Command events while the LinkButton control has them, which can be handled in the code-behind file of the Web page.
43. Differentiate between authentication and authorization.
- Authentication : Authentication is the process of verifying the identity of a user using some credentials like username and password.
- Authorization : Authorization determines the parts of the system to which a particular identity has access.
44. How many web.config files allowed in an application?
Multiple web.config files can be placed in an application. A Web.config file can be placed in a folder to override the configuration inherited from root web.config.
45. What is Cross Page Posting?
ASP.NET submits a form to the same page however page can be submitted to another page using the ‘PostBackUrl’ property of the button(that causes postback) to the desired page. This is called cross page posting.
46. What is Reflection in .NET?
To get the meta data information i.e types defined of an assembly Reflection can be used. The System. Reflection namespace will have the classes required for reflection.
47. Define Resource Files.
Resource files contains non-executable data like strings, images etc in binary format so it is lightweight. that can be used by an application and deployed along with it.
48. What are the Navigations technique in ASP.NET?
- Response.Redirect:It redirects a client to a new URL. Specifies the new URL and whether execution of the current page should terminate.(MSDN)
- Server.Transfer: Moves to another web page without changing the url.
- Server.Exceute: It merges the content of target web page into source web page.
- Cross page posting: Different page can be submitted on click of submit button.
In ASP NET interview questions answers I have tried to cover almost all topics of ASP NET. However in interview question on ASP.NET could be random but my experience says generally interviewer starts from basic questions and moves on advance questions. So I except "ASP NET interview questions answers" article will help you for preparing your job interview.