ASP.NET interview question pdf – ASP.NET Interview Questions and Answers for Freshers

ASP.NET interview question pdf: We have compiled most frequently asked .NET Interview Questions which will help you with different expertise levels.

C#.NET Interview Questions and Answers for Freshers Pdf Free Download

Question 1.
What is ASP.Net?
It is a framework developed by Microsoft on which we can develop new generation websites 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 websites. There are various page extensions provided by Microsoft that are being used for website development. Eg: aspx, asmx, ascx, ashx, cs, vb, HTML, XML etc.

Question 2.
What are the advantages of ASP.NET?
ASP.Net is the next generation of ASP technology platform. It is superior to ASP in the following ways:

  • Highly Scalable
  • Compiled Code
  • User Authentication
  • Language Support
  • Third-party control
  • Configuration and Deployment are easy,
  • Object and Page caching
  • Strict coding requirements

Question 3.
What’s the use of Response.Output.Write( )?
We can write formatted output using Response.Output.Write( ).

Question 4.
In which event of page cycle is the ViewState available?
After the lnit( ) and before the Page_Load().

Question 5.
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 client url history list or current url Server does not update in the case of the Server. Transfer.

Response. Redirect is used to redirect the user’s browser to another page or site. It performs a 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.

Question 6.
From which base class all Web Forms are inherited?
Page class.

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

Question 8.
Which validator control do you use if you need to make sure the values in two different controls matched?
Compare Validator control.

Question 9.
What is the concept of Postback in ASP.NET?
Postback is a request which is sent from a client to the server from the same page user is working with. There is an HTTP POST request mechanism in ASP.NET. It posts a complete page back to the server to refresh the whole page.

Question 10.
What is the use of “isPostBack” property?
The “IsPostBack” property of the page object is used to check that the page is posted back or not.

Question 11.
How do you identify that the Page is PostBack?
There is a property named “IsPostBack” property in Post object, which can be checked to know that the page is posted back.

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

Question 13.
Where the ViewState is stored after the page postback?
ViewState is stored in a hidden field on the page on the 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.

Question 14.
How long the items in ViewState exists?
They exist for the life of the current page.

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

  1. In-Process
  2. Out-of-Process.

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.

Question 16.
How you can add an event handler?
Using the Attributes property of server side control, e.g.
btnSubmit.Attributes.Add(“onMouseOver,,;,,JavascriptCode( );”)

Question 17.
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.

Question 18.
what are the main requirements for caching?

  • By caching the response, your request is served by the response already stored in memory.
  • You must be very careful while choosing the items to cache because Caching incurs overhead.
  • A frequently used web form which data doesn’t frequently change is good for caching.
  • A cached web form freezes form?s server-side content, and changes to that content do not appear until the cache is refreshed.

Question 19.
What are the different types of caching?ASP.NET has 3 kinds of caching :

  1. Output Caching,
  2. Fragment Caching,
  3. Data Caching.

Question 20.
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:
<%@ OutputCache Duration=”120″ VaryByParam=”CategorylD;SelectedlD”%>

Question 21.
List the events in page life cycle.

  1. Page_Prelnit
  2. Page_lnit
  3. Page_lnitComplete
  4. Page_PreLoad
  5. Page_Load
  6. Page_LoadComplete
  7. Page_PreRender
  8. Render

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

Question 23.
What is the difference between ASP.NET Webforms and ASP.NET MVC?
ASP.NET Webforms uses the page controller approach for rendering layout. In this approach, every page has its controller.
On the other hand, ASP.NET MVC uses the Front Controller approach. In this approach, there is a common controller for all pages.

Question 24.
Is it possible to create a web application with both webforms and MVC?
Yes. We have to include the below MVC assembly references in the web forms application to create a hybrid application.



System. ComponentModel.DataAnnotations

Question 25.
Can we add code files of different languages in the App_Code folder?
No. The code files must be in the same language to be kept in the App_code folder.

Question 26.
What is Protected Configuration?
It is a feature used to secure connection string information.

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

MailMessage mailMess = new MailMessage ( );
mailMess.From = "
mailMess.To = "";
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.

Question 28.
How can we prevent browser from caching an ASPX page?
We can SetNoStore on HttpCachePolicy object exposed by the Response object’s Cache property:

Response.Cache.SetNoStore ( );
Response.Write (DateTime.Now.ToLongTimeString ());

Question 29.
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.

Question 30.
What is the use of Global.asax file?
The Global.asax file is used to execute the application-level events and sets application- level variables.

Question 31.
What is event bubbling?
When child control sends events to parent, it is termed as event bubbling. Server controls like Data Grid, Data List, and Repeater can have other child controls inside them.

Question 32.
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, Application_UpdateRequestCache

Session Events: Session_Start,Session_End

Question 33.
Which protocol is used to call a Web service?
HTTP Protocol

Question 34.
Can we have multiple web config files for an application?

Question 35.
What is the difference between web config and machine config?
Web config file is specific to a web application where as machine config is specific to a machine or server. There can be multiple web config files into an application where as we can have only one machine config file on a server.

Question 36.
Explain role based security ?
Role-based security is used in almost all organization, and the Role-based security assigns certain privileges to each role.

  • Each user is assigned a particular role from the list.
  • Privileges as per role restrict the user’s actions on the system and ensure that a user can do only what he is permitted to do on the system.
<AUTHORIZATION>< authorization >
< allow roles="Domain_Name\Administrators" / > < !-- Allow Administrators in domain. 
 — >
< deny users-'*" />                             < !-- Deny anyone else. -- >
< /authorization >

Question 37.
What is Cross Page Posting?
When we click submit button on a web page, the page post the data to the same page. The technique in which we post the data to different pages is called Cross Page posting. This can be achieved by setting POSTBACKURL property of the button that causes the postback. Findcontrol method of PreviousPage can be used to get the posted values on the page to which the page has been posted.

Question 38.
How can we apply Themes to an application?
We can specify the theme in web.config file. Below is the code example to apply the theme:



<pages theme="Windows7" />



Question 39.
What is RedirectPermanent in ASP.Net?
RedirectPermanent Performs a permanent redirection from the requested URL to the specified URL. Once the redirection is done, it also returns 301 Moved Permanently responses.

Question 40.
What is MVC?
MVC is a framework used to create web applications. The web application base builds on Model-View-Controller pattern which separates the application logic from Ul, and the input and events from the user will be controlled by the Controller.

Question 41.
Explain the working of passport authentication.
First of all it checks passport authentication cookie. If the cookie is not available then the application redirects the user to Passport Sign on page. Passport service authenticates the user details on sign on page and if valid then stores the authenticated cookie on client machine and then redirect the user to requested page

Question 42.
What are the advantages of Passport authentication?
All the websites can be accessed using single login credentials. So no need to remember login credentials for each web site.

Users can maintain his/ her information in a single location.

Question 43.
What are the Security Controls?

  • <asp:Login>: Provides a standard login capability that allows the users to enter their credentials
  • <asp:Loginl\lame>: Allows you to display the name of the logged-in user
  • <asp:LoginStatus>: Displays whether the user is authenticated or not
  • <asp:LoginView>: Provides various login views depending on the selected template
  • <asp:PasswordRecovery>: email the users their lost password

Question 44.
How do you register JavaScript for webcontrols ?
We can register javascript for controls using <CONTROL -name>Attribtues.Add(scriptname,scripttext) method.

Question 45.
In which event are the controls fully loaded?
Page load event.

Question 46.
what is boxing and unboxing?
Boxing is assigning a value type to reference type variable. Unboxing is reverse of boxing ie. Assigning reference type variable to value type variable.

Question 47.
Differentiate strong typing and weak typing
In strong typing, the data types of variable are checked at compile time. On the other hand, in case of weak typing the variable data types are checked at runtime. In case of strong typing, there is no chance of compilation error. Scripts use weak typing and hence issues arises at runtime.

Question 48.
How we can force all the validation controls to run?
The Page.Validate( ) method is used to force all the validation controls to run and to perform validation.

Question 49.
List all templates of the Repeater control.

  • ItemTemplate
  • AlternatingltemTemplate
  • SeparatorTemplate
  • HeaderTemplate
  • FooterTemplate

Question 50.
List the major built-in objects in ASP.NET?

  • Application
  • Request
  • Response
  • Server
  • Session
  • Context

Question 51.
What is the appSettings Section in the web.config file?
The appSettings block in the web config file sets the user-defined values for the whole application.
For example, in the following code snippet, the specified Connectionstring section is used throughout the project for database connection:

<add key-'ConnectionString" value="server=local; pwd=password; database=default" /> 

Question 52.
Which data type does the RangeValidator control support?
The data types supported by the RangeValidator control are Integer, Double, String, Currency, and Date.

Question 53.
What is the difference between an HtmllnputCheckBox control and an HtmllnputRadioButton control?
In HtmllnputCheckBoxcontrol, multiple item selection is possible whereas in HtmllnputRadioButton controls, we can select only single item from the group of items.

Question 54.
Which namespaces are necessary to create a localized application?

Question 55.
What is a cookie?
A Cookie is a small piece of information which is stored at the client side. There are two types of cookie:

  • Session/Temporary Cookie: valid for a single session
  • Persistent Cookie: valid for multiple session

Question 56.
What is the default timeout for a cookie?
30 minutes.

Question 57.
How would you turn off cookies on a page of a website?
You have to follow the procedures given below:

  • Use the “Cookie.Discard” property,
  • It gets or sets the discard flag set by the server.
  • When set to true, this property instructs the client application not to save the Cookie on the hard disk of the user at the end of the session.

Question 58.
What are the different types of cookies in ASP.NET?
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.

Question 59.
What is the file extension of web service?
Web services have file extension .asmx..

Question 60.
What are the components of ADO.NET?
The components of ADO.Net are Dataset, Data Reader, Data Adaptor, Command, connection.

Question 61.
What is the difference between ExecuteScalar and ExecuteNonQuery?
ExecuteScalar returns output value where as ExecuteNonQuery ctoes not return any value but the number of rows affected by the query. ExecuteScalar used for fetching a single value and ExecuteNonQuery used to execute Insert and Update statements.

Question 62.
What is IIS?
IIS stands for Internet Information Services. It is created by Microsoft to provide Internet-based services to ASP.NET Web applications.

Question 63.
What is the usage of IIS?
Following are the main usage of IIS:

  • IIS is used to make your computer to work as a Web server and provides the functionality to develop and deploy Web applications on the server,
  • IIS handles the request and response cycle on the Web server,
  • IIS also offers the services of SMTP and Frontpage server extensions.
  • The SMTP is used to send emails and use Frontpage server extensions to get the dynamic features of IIS, such as form handler.

Question 64.
What is a multilingual website?
If a website provides content in many languages, it is known as a multilingual website. It contains multiple copies of its content and other resources, such as date and time, in different languages.

Question 65.
What is the parent class of all web server control?
System. Web. Ul.Control class

Question 66.
What is the difference between the GET method () and POST method ()?

Data is affixed to the URL.
Data is not secured.
Data transmission is faster in this method.
It is a single call system.
Only a limited amount of data can be sent.
It is a default method for many browsers.


Data is not affixed to the URL Data is secured.
Data transmission is comparatively slow
It is a two call system
A large amount of data can be sent
It is not set as default. It should be explicitly specified

Question 67.
What is the difference between session object and application object?
The session object is used to maintain the session of each user. A session id is generated if a user enters in the application and when the user leaves the application, the session id is automatically deleted.
On the other hand, the application object is used to store the information and access variables from any page in the application.
Debug class is used to debug builds. Trace class is used for both debug and release builds.

Question 68.
What is the difference between trace and debug?
Debug class is used to debug builds. Trace class is used for both debug and release builds.

Question 69.
What is the difference between client-side and server-side validations in WebPages?
The client-side validation happens at the client’s side with the help of JavaScript and VBScript. This validation has occurred before the Web page is sent to the server. The server-side validation happens at the server side.

Question 70.
What is the difference between file-based dependency and key-based dependency?
File-based dependency: File-based dependency facilitates you to save the dependency on a file in a disk.
Key-based dependency: In key-based dependency, you depend on another cached item.

Question 71.
What is the difference between globalization and localization?
Globalization: Globalization is a technique to identify the part of a Web application that is different for different languages and separate it out from the web application.

Localization: In localization, you try to configure a Web application so that it can be supported for a specific language or locale.

Question 72.
What is the difference between a page theme and a global theme?
Page Theme: The page theme is applied to particular web pages of the project. It is stored inside a subfolder of the App_Themes folder.
Global Theme: The Global theme is applied to all the web applications on the web server. It is stored inside the Themes folder on a Web server.

Question 73.
What is the difference between early binding and late binding?
Early Binding: In early binding, a non-virtual method is called which is decided at a compile time.
Late Binding: In late binding, a virtual method is called which is decided at runtime.

Question 74.
What is the difference between server-side scripting and client-side scripting?
Server-side scripting: In server-side scripting, all the script are executed by the server and interpreted as needed.

Client-side scripting: In client-side scripting, the script will be executed immediately in the browser such as form field validation, email validation, etc. The client-side scripting is usually carried out in VBScript or JavaScript.

Question 75.
How to sign out from forms authentication?
FormsAuthentication.Signout() method is used to sign out from forms authentication.

Question 76.
How to display validation messages in one control?
By the help of ValidationSummary control, we can display all validation messages in one control.

Question 77.
What is the difference between authentication and authorization?
Authentication is a process of identifying user whereas authorization is used to check the access rights of an identified user.

Question 78.
Which object encapsulates state or data of a user?
Session object.

Question 79.
What are the differences between the Response.Write() and Response.Output.Write()?
Response.Write( ) is used for normal output whereas Response.Output.Write() is used for formatted output.

Question 80.
Define the types of configuration files.
There are two types of configuration files:

  • Application Level config = Web.config.
  • Machine Level config = Machine.config.

Question 81.
What is the difference between Web config and Machine config files?
Web config file is specific to web application whereas Machine config file is specific to machine or server.
There can be multiple web config files in an application but only one machine config file.

Question 82.
What are the HTML server controls in ASP.NET?

  • HTML server controls are just like HTML elements that we use on HTML pages.
  • HTML server controls are used to expose properties and events for use.
  • To make these controls programmatically accessible, we specify that the HTML controls act as a server control by adding the runat=Mserver” attribute.