ASP-NET Interview Questions

ASP.NET Interview questions for beginners and professionals to help them in their job interviews. The questions are created and submitted by experts to help you.

Q.1 How do you define GAC?
GAC refers to Global Assembly Cache. Therefore whenever CLR gets installed on the machine such that GAC comes as a part of it. The GAC specifically stores those assemblies that will be shared by many applications. In which case a Developer tool called Gacutil.exe is used to add any file to GAC.
Q.2 State the events in which controls fully loaded?
The page load event guarantees that all controls are fully loaded. Such that Controls are also accessed in Page_Init events but you will see that view state is not fully loaded during this event.
Q.3 Define ASP.
ASP stands for Active Server Pages that refer to a server-side technology provided by Microsoft which is used to create dynamic and user-friendly web pages. It uses different scripting languages for creating dynamic web pages which can be run on any browser.
Q.4 What is ASP.NET?
ASP.Net is a specification by Microsoft which is used for creating web applications and web services. It is a part of the ".Net framework". You can create ASP.Net applications in most of the .Net compatible languages like Visual Basic, C#, etc. ASP.Net provides much better performance than scripting languages.
Q.5 What is IIS? Explain its use.
IIS stands for Internet Information Services that is created by Microsoft for providing Internet-based services to ASP.NET Web applications. ISS is used for: Making your computer work as a Web server and providing the functionality to develop and deploy Web applications on the server. Handling the request and response cycle on the Web server. Providing the services of SMTP and FrontPage server extensions. Sending emails and using FrontPage server extensions to get the dynamic features of IIS, such as form handler.
Q.6 Define a multilingual website.
If a website provides content is 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.
Q.7 Describe the advantages of ASP.NET.
ASP.Net is the next generation of ASP technology platform. It is superior to ASP by providing: Highly Scalability Compiled Coding User Authentication Language Support Third-party control Object and Page caching Strict coding requirements
Q.8 Define Postback in ASP.NET.
Postback refers to 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.
Q.9 What is Client-Side and Server-Side Validation?
When validation is completed on the client browser, then it is known as Client-Side Validation. We use JavaScript to do the Client-Side Validation. And, Server-Side Validation is when validation occurs on the server, then it is known as Server-Side Validation. Server-Side Validation is a secure form of validation. The main advantage of Server-Side Validation is if the user somehow bypasses the Client-Side Validation, we can still catch the problem on the server-side.
Q.10 Define View State.
View State is the technique for preserving the Value of the Page and Controls between round trips. It is a Page-Level State Management technique that is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.
Q.11 What is the process of themes in the ASP.NET application?
A theme is a collection of settings that specify the look of controls and web pages. These themes are applied across all the pages in a web application to maintain a consistent appearance. Themes are included images and skin files. And, the skin files set the visual properties of ASP.NET controls. Further, themes are of two types: Firstly, the Page theme contains the control skins, style sheets, graphic files, and other resources inside the subfolder of the App_Theme folder in the Solution Explorer window. A page theme is applied to a single page of the website. Secondary, Global Theme is a theme that is applied to all the websites on a web server and includes property settings, and graphics. This theme allows us to maintain all the websites on the same web server and define the same style for all the web pages of the websites.
Q.12 Why should you close all database objects and set them to NULL before leaving the method where the objects were created
To ensure that the connection to the database is closed as soon as possible.
Q.13 What do you understand about MVC?
Model-View-Controller (MVC) is a pattern for separating an application into the following three main components: Model View Controller The ASP.NET MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating web applications. Further, the MVC framework is defined in the System.Web.MVC assembly. It provides full control over HTML, JavaScript, and CSS.
Q.14 What is assembly?
Assembly is a collection of files that appear to the programmer to be a single DLL or EXE.
Q.15 Define Ajax in ASP.NET.
Ajax stands for Asynchronous JavaScript and XML that is the combination of various technologies such as JavaScript, CSS, XHTML, DOM, etc. AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the entire page. Further, it also supports the open-source implementation of other technology and partially renders the page to the server instead of the complete page being postback. We use AJAX for developing faster, better, and more interactive web applications.
Q.16 What’s the difference between Class and structure?
1. Structure are value types and classes are reference types.So structures use stack and classes use heap 2. Structures members can not be declared as protected , but class members can be.You can not do inheritance in structures 3. Structures do not require constructors while classes require.
Q.17 Explain the Application Domain Concept in ASP.NET.
ASP.NET introduces the concept of an Application Domain which is known as AppDomain. It can be considered as a lightweight process that is both a container and boundary. The .NET runtime uses an AppDomain as a container for code and data, just like the operating system uses a process as a container for code and data. As the operating system uses a process for isolating misbehaving code, the .NET runtime uses an AppDomain to isolate code inside a secure boundary. The CLR can allow the multiple .NET applications to run in a single AppDomain.
Q.18 You need to dynamically add a TextBox control to a page and display it at specific location.
Place a PlaceHolder control at the required location in the page. Use the Add method of the Controls collection of the PlaceHolder control to dynamically add the required control
Q.19 Define the term tracing in .NET.
Tracing helps in seeing the information of issues at the runtime of the application. By default Tracing is disabled. Tracing has the following important features which allow to: Firstly, see the execution path of the page and application using the debug statement. Secondly, access and manipulate trace messages programmatically. Thirdly, see the most recent tracing of the data.
Q.20 What happens after adding the attribute trace="TRUE" to the <%@Page%> directive in an ASP.NET page?
ASP.NET will generate and display diagnostic information at the bottom of the rendered page.
Q.21 Explain the types of tracing.
Tracing can be done with the following 2 types. Firstly, Page Level. When the trace output is shown on the page and for the page-level tracing we need to set the property of tracing at the page level. <%@ Page Trace="true" Language="C#" Secondly, Application Level. In this, the information is stored for each request of the application. The default number of requests for storing is 10. But if you want to increase the number of requests and discard the older request and display a recent request then you need to set the property in the web.config file.
Q.22 Define session object and application object.
The session object is used for maintaining the session of each user. A session id is generated if a user enters the application and when the user leaves the application, the session id is automatically deleted. Whereas, the application object is used for storing the information and access variables from any page in the application.
Q.23 Define globalization and localization.
Globalization is a method for identifying the part of a Web application that is different for different languages and separate it out from the web application. And, in localization, you try to configure a Web application so that it can be supported for a specific language or locale.
Q.24 Explain the term early binding and late binding.
In early binding, a non-virtual method is called which is decided at a compile-time. On the other hand, in late binding, a virtual method is called which is decided at runtime.
Q.25 Explain the major difference between Web config and Machine config files.
The web config file is specific to the web applications whereas the Machine config file is specific to machines or servers. Secondly, there can be multiple web config files in an application but only one machine config file.
Q.26 Define Role-based security.
Role-based security is used in almost all organizations. This certain privileges to each role. For example, Firstly, every user is allocated a particular role from the list. Secondly, 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.
Q.27 Can you tell the file extension of the web service?
The File extension of the web service is .asmx.
Q.28 Define the HTML server controls in ASP.NET?
HTML server controls are just like HTML elements that we use on HTML pages. They are used for exposing properties and events for use. However, for making these controls programmatically accessible, we define that the HTML controls act as a server control by adding the runat="server" attribute
Q.29 What do you know about event bubbling?
When child control sends events to parents, it is termed event bubbling. Server controls like Data Grid, Data List, and Repeater can have other child controls within them.
Q.30 Name the major events in global.aspx.
The Global.asax file, which is derived from the HttpApplication class, maintains a pool of HttpApplication objects and allocates them to applications as required. However, the events in the Global.asax file are: Application_Init Application_Disposed Application_Error Application_Start Application_End Application_BeginReques
Q.31 Name the Navigations techniques in ASP.NET.
Navigation can cause data loss if it not properly handled. However, there are many techniques for transferring data from one page to another but every technique has its own importance and benefits. This include: Response.Redirect Server.Transfer Server.Execute Cross page posting
Q.32 Name the built-in objects in ASP.NET.
The major built-in objects are: Application Session Context Request Response Server Trace
Q.33 What do you understand by XHTML? Also confirm if ASP.NET Pages compliant with XHTML?
XHTML is a stricter and cleaner version of HTML. XHTML stands for EXtensible Hypertext Markup Language and is a W3C Recommendation. Yes, ASP.NET 2.0 Pages are XHTML compliant. However the facility has been given to the user to add the applicable document type declaration.
Q.34 What is the ideal size of a ViewState and how does it affect performance? How can you compress a viewstate?
Viewstate stores the state of controls in HTML hidden fields. Many a times, this information can grow in capacity. This does affect the comprehensive responsiveness of the page, thereby affecting performance. The optimal size of a viewstate should be not more than 25-30% of the page size. Also ViewState can be compressed to almost 50% of its size. .NET also provides the GZipStream orDeflateStream to compress viewstate
Q.35 How can we detect if a viewstate is tampered?
We detect if a viewstate is tampered by setting the EnableViewStateMac to true in the @Page directive. This attribute checks the encoded and encrypted viewstate for tampering.
Q.36 Does the App_Code folder contain source code files in different programming languages?
No, all source code files stored in the root App_Code folder must be in the same programming language. Although we can create two subfolders inside the App_Code and then add both C# and VB.NET in the respective subfolders. Also we have to add configuration settings in the web.config for this to work.
Q.37 How can we deploy the application without deploying the source code on the server?
We can complicate the code by using a new precompilation process called ‘precompilation for deployment’. You can use the aspnet_compiler.exe to precompile a site. Such that this process builds each page in your web application into a single application DLL and some placeholder files. Also these files can then be deployed to the server.
We can also conclude the same task using Visual Studio 2005 by using the Build->Publish menu.
Q.38 How can we use different programming languages in the same application?
Yes each page can be written with a different programming language in the same application. We can also create a few pages in C# and a few in VB.NET.
Q.39 How can we secure the connection string information?
We can secure the connection string information by using the Protected Configuration feature.
Q.40 What is Cross Page Posting and how is it performed?
It by default that ASP.NET submits a form to the same page. Such that in cross-page posting, the form is being submitted to a different page. This is performed by setting the ‘PostBackUrl’ property of the button(that causes postback) to the desired page. Such that in the code-behind of the page to which the form has been posted, use the ‘FindControl’method of the ‘PreviousPage’ property to reference the data of the control in the first page.
Q.41 How can we change a Master Page dynamically at runtime and how?
In order to change a master page, set the MasterPageFile property to point to the .master page during the PreInit page event.
Q.42 How can we secure configuration files to be accessed remotely by unauthorized users?
ASP.NET configures IIS which does not give access to any user that requests access to the Machine.config or Web.config files.
Q.43 How many web.config files can we have in an application?
We can keep multiple web.config files in an application. This can be done by placing a Web.config file inside a folder or whenever we need to override the configuration settings that are inherited from a configuration file located at a higher level in the hierarchy.
Q.44 How do you define caching in ASP.NET?
We can define caching as one of the most interesting concept and operation in ASP.NET. Also we can handle it, if we can run any web application by applying the caching concept depending on the requirements.Caching is primarily used for providing solutions or the results to the users depending on their request, admin needs to recreate the pages often depending on user requests. Such that a cache simply stores the output generated by a page in the memory and this saved output (cache) will serve us (users) in the future. Types of caching including - Page Caching, Fragment Caching and Data Caching.
Q.45 List the major events in global.aspx?
The Global.asax file, that is derived from the HttpApplication class, maintains a pool of HttpApplication objects, and assigns them to applications as needed. Such that the Global.asax file contains the listed events like -
1. Application_Init
2. Application_Disposed
3. Application_Error
4. Application_Start
5. Application_End
6. Application_BeginReques
Q.46 In the Page directive, what is use of the AutoEventWireup attribute?
AutoEventWireUp is a boolean attribute which permits automatic wireup of page events when this attribute is set to true on the page. It is set to True by default for a C# web form whereas it is set as False for VB.NET forms. The pages developed with Visual Studio .NET have this attribute set to false, and page events are individually tied to handlers.
Q.47 What will happen if we change the web.config file at run time?
If we change the web.config file at run time then ASP.NET invalidates the existing cache and assembles a new cache. Then ASP.NET automatically restarts the application to apply the changes.
Q.48 How do you define Cookies in ASP.NET?
Cookies can be defined as a State Management Technique which store the values of control after a post-back. Such that cookies can store user-specific Information on the client’s machine like when the user last visited your site. Cookies are also referred by many names, like HTTP Cookies, Browser Cookies, Web Cookies, Session Cookies and so on. Primarily, cookies are a small text file sent by the web server and saved by the Web Browser on the client’s machine.
Q.49 How can you differentiate between session and caching?
Primary difference between session and caching is firstly it us a session is per-user based but caching is not per-user based, this means Session data is stored at the user level but caching data is stored at the application level and shared by all the users. This indicates that it is simply session data that will be different for the various users for all the various users, such that session memory will be allocated differently on the server but for the caching only one memory will be allocated on the server and if one user modifies the data of the cache for all, the user data will be modified.
Q.50 How can you define tracing in .NET?
We can define tracing as a means to see the information of issues at the runtime of the application. By default Tracing is disabled. Tracing has the given important features -
1. See through the execution path of the page and application using the debug statement.
2. Access and manipulate trace messages programmatically.
3. See the most recent tracing of the data.

Tracing can be performed with the following 2 types -
1. Page Level: When the trace output is displayed on the page and for the page-level tracing we need to set the property of tracing at the page level.<%@ Page Trace=”true” Language=”C#”
2. Application: Level: In Application-Level tracing the information is stored for each request of the application. The default number of requests to store is 10. But if you want to increase the number of requests and discard the older request and display a recent request then you need to set the property in the web.config file.
Get Govt. Certified Take Test