ASP.NET Interview Questions

ASP.NET Interview Questions

Q. What is ASP.Net?

It is a framework developed by Microsoft on which we can develop new generation web sites using web forms(aspx), MVC, HTML, Javascript, CSS etc. Its successor of Microsoft Active Server Pages(ASP). Currently there is ASP.NET 4.0, which is used to develop web sites. There are various page extensions provided by Microsoft that are being used for web site development. Eg: aspx, asmx, ascx, ashx, cs, vb, html, XML etc.

Q. What’s the use of Response.Output.Write()?

We can write formatted output using Response.Output.Write().

Q. In which event of page cycle is the ViewState available?

After the Init() and before the Page_Load().

Q. What is the difference between Server.Transfer and Response.Redirect?

In Server.Transfer page processing transfers from one page to the other page without making a round-trip back to the client’s browser. This provides a faster response with a little less overhead on the server. The clients url history list or current url Server does not update in case of Server.Transfer.

Response.Redirect is used to redirect the user’s browser to another page or site. It performs trip back to the client where the client’s browser is redirected to the new page. The user’s browser history list is updated to reflect the new address.

Q. From which base class all Web Forms are inherited?

Page class

Q. What are the different validators in ASP.NET?

1. Required field Validator
2. Range Validator
3. Compare Validator
4. Custom Validator
5. Regular expression Validator
6. Summary Validator

Q. Which validator control you use if you need to make sure the values in two different controls matched?

Compare Validator control.

Q. What is ViewState?

ViewState is used to retain the state of server-side objects between page post backs.

Q. Where the viewstate is stored after the page postback?

ViewState is stored in a hidden field on the page at client side. ViewState is transported to the client and back to the server, and is not stored on the server or any other external source.

Q. How long the items in ViewState exists?

They exist for the life of the current page.

Q. What are the different Session state management options available in ASP.NET?



In-Process stores the session in memory on the web server.
Out-of-Process Session state management stores data in an external server. The external server may be either a SQL Server or a State Server. All objects stored in session are required to be serializable for Out-of-Process state management.

Q. How you can add an event handler?

Using the Attributes property of server side control.
1 btnSubmit.Attributes.Add(“onMouseOver”,”JavascriptCode();”)

Q. What is caching?

Caching is a technique used to increase performance by keeping frequently accessed data or files in memory. The request for a cached file/data will be accessed from cache instead of actual location of that file.

Q. What are the different types of caching?

ASP.NET has 3 kinds of caching :
1. Output Caching,
2. Fragment Caching,
3. Data Caching.

Q. Which type if caching will be used if we want to cache the portion of a page instead of whole page?

Fragment Caching:It caches the portion of the page generated by the request. For that, we can create user controls with the

below code:

1 <%@ OutputCache Duration=”120″ VaryByParam=”CategoryID;SelectedID”%>

Q. List the events in page life cycle.

1) Page_PreInit

2) Page_Init

3) Page_InitComplete

4) Page_PreLoad

5) Page_Load

6) Page_LoadComplete

7) Page_PreRender


Q.Can we have a web application running without web.Config file?


Q.Is it possible to create web application with both webforms and mvc?

Yes. We have to include below mvc assembly references in the web forms application to create hybrid application.


Q. Can we add code files of different languages in App_Code folder?

No. The code files must be in same language to be kept in App_code folder.

Q.What is Protected Configuration?

It is a feature used to secure connection string information.

Q.  Write code to send e-mail from an ASP.NET application?

MailMessage mailMess = new MailMessage ();
mailMess.From = “abc@gmail.com”;
mailMess.To = “xyz@gmail.com”;
mailMess.Subject = “Test email”;
mailMess.Body = “Hi This is a test mail.”;
SmtpMail.SmtpServer = “localhost”;
SmtpMail.Send (mailMess);

MailMessage and SmtpMail are classes defined System.Web.Mail namespace.

Q. How can we prevent browser from caching an ASPX page?

We can SetNoStore on HttpCachePolicy object exposed by the Response object’s Cache property:
1 Response.Cache.SetNoStore ();
2 Response.Write (DateTime.Now.ToLongTimeString ());

Q. What is the good practice to implement validations in aspx page?

Client-side validation is the best way to validate data of a web page. It reduces the network traffic and saves server resources.

Q. What are the event handlers that we can have in Global.asax file?

Application Events:
Application_Start , Application_End, Application_AcquireRequestState, Application_AuthenticateRequest, Application_AuthorizeRequest, Application_BeginRequest, Application_Disposed, Application_EndRequest, Application_Error,

Application_PostRequestHandlerExecute, Application_PreRequestHandlerExecute, Application_PreSendRequestContent, Application_PreSendRequestHeaders,
Application_ReleaseRequestState, Application_ResolveRequestCache,
Session Events: Session_Start,Session_End

Q. Which protocol is used to call a Web service?

HTTP Protocol

Q. Can we have multiple web config files for an asp.net application?


Q. What is ASP.Net MVC?

The ASP.NET MVC is a framework for developing web based application using general Model View Controller pattern in ASP.NET. It provides an alternative to ASP.NET Web Forms pattern. It is a very powerful and efficient way to separate the concern with in an application. The MVC pattern has following main components:

  1. Model:The Model represents a set of classes that describes the data you are working with and business logic. It also defines the business rules for how the data can be changed and manipulated.
  2. The View:The View transforms a model or models into UI. The view is responsible for displaying the data that is received from the controller as the result.
  3. The Controller:The Controller is responsible for controlling the overall application logic and acts as a coordinator between the View and the Model.

Q. What is Razor?

Razor is a view engine. View engine is responsible for rendering the HTML view of the page to the browser. It is an advanced view engine, introduced with MVC3. Razor syntax are advanced, compact and easy to learn. By default ASP.NET MVC supports two view engines: ASPX and Razor.

Q. What is ViewData and ViewBag?

ViewBag and ViewData are two options which are used to pass information from controller to view in ASP.Net MVC. Both have short life.  Short life means value of both becomes null when redirection occurred. This is because their purpose is to provide communication between views and controllers.

Q. How many types of ASP.NET are currently released?

The current version of ASP.NET is at 4.0; previous versions include 1, 1.1, 2.0 and 3.5. The current version is more concentrated on AJAX and LINQ. Version 3.0 of ASP.NET does not exist.

Q. What does ASP.NET 2.0 improve over the previous version?

ASP.NET 2.0 improves by adding new features such as: master pages, new controls, themes, security, profiles and more.

Q. What does ASP.NET AJAX do?

ASP.NET AJAX gives the user a great deal of options that help integrate AJAX into normal ASP.NET pages. It ensures that users can write more powerful JavaScript.

Q. What is LINQ and what does it do?

LINQ means Language Integrated Query and is an extension to the C# and VB languages. It allows for writing of these languages codes that manipulate in-memory data just like querying a database.

Q. Do current web browsers support ASP.NET 3.5? What is the role of ASP.NET in web development?

Yes, Current browser versions fully support ASP.NET 3.5(IE 5, Opera 7.6, Safari 1.2 and Firefox 1.0). ASP.NET is designed to provide a client callback feature that handles some of the work web browsers should handle.

Q. Is ASP.NET 3.5 a full ASP.NET version?

No ASP.NET 3.5 is designed to add features over the 2.0 version and the most important ones are: CLR and WCF. New 3.5 version list of important assemblies consists of:

  1. a) System – core;
  2. b) Data.Linq;
  3. c) data.DataSetExtension;
  4. d) Xml.Linq and
  5. e) Web.Extensions – dll.

Q. How do you add ASP.NET into a web site?

After creating a new web site you can add ASP.NET by going to the option menu, selecting add new item; you then select web form and enter the value FirstPage.aspx.

Q. What are web forms and what do they do?

Web forms allow the creation of a web based application that uses the same interface as Windows applications.

Q. What is page processing?

Page processing allows ASP.NET to execute the web server on the server by a technique called postback. It also enables ASP to create a seamless user experience where web applications are stateless.

Q. How are controls handled in ASP.NET?

Controls are placed in a <form> tag that is marked with the runat=”server” attribute, thus allowing the user to work on the server side of the application.

Q. What is the ASP.NET event model?

ASP.NET provides a change to the linear processing model because of its event driven model. By providing, each event handler with a discrete method, the page code becomes organized and clean.

Q. How do the events in ASP.NET function?

The events allow ASP.NET to create pages and control objects so that the newly created page can run smooth; it also triggers a postback and intercepts the returned page recreating the page objects; it then checks the operations triggered by the postback and finally renders the HTML page and returns it to the client.

Q. What is the view state mechanism in ASP.NET?

To deal with the limitations of HTML, ASP has an integrated state serialization mechanism. It means that properties of a certain page that get changed enable ASP to make notes and keep track of them.

Q. Does ASP.NET follow the rules of XHTML?

Yes. The core ASP controls follow the XHTML rules and to make sure the page is compliant with XHMTL the users have to make sure the static content they add follows these rules.

Q. How does the user code initialize?

It is done by using the Page.Load event in the stage of processing of a page. This event always sets off no matter if the page is being requested for the first time or part of a postback.

Q. Does ASP.NET include validation controls?

Yes it does. These controls fire before a page is loaded but before the actual events take place. By having the validation controls self-sufficient ASP.NET does not make it mandatory for the user to respond to them.

Q. What is the Response object in ASP.NET?

The Response object is an instance of the System.Web.HttpResponse class and is the server’s response to a class. It provides important functionality: cookie features and the Redirect () method.

Q. What is the Server object?

The Server object is an instance of the System.Web.HttpServerUtility class and it provides miscellaneous methods and properties that help the web server.

Q. What is the User object?

The User object shows information about the user making a request to a web server and it allows the users to see the user’s role membership by implementing the System.Security.Principal.IPrincipal.


0 Responses on ASP.NET Interview Questions"

Leave a Message

Your email address will not be published. Required fields are marked *

Copy Rights Reserved © Mindmajix.com All rights reserved. Disclaimer.