ASP.NET Interview Questions

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

A new instance of the Web page class is created each time the page is posted to the server.
In traditional Web programming, all information that is associated with the page, along with the controls on the page, would be lost with each roundtrip.
The Microsoft ASP.NET framework includes several options to help you preserve data on both a per-page basis and an application-wide basis. These options can be broadly divided into the following two categories,
Client-Side State Management Options
Server-Side State Management Options

Client-Side State Management

Client-based options involve storing information either in the page or on the client computer.
Some client-based state management options are,
Hidden fields
View state
Query strings

Server-Side State Management

There are situations where you need to store the state information on the server side.
Server-side state management enables you to manage application-related and session-related information on the server.
ASP.NET provides the following options to manage state at the server side:
Application state
Session state

Q. Differentiate between file-based dependency and key-based dependency.
– In file-based dependency, the dependency is on a file saved in a disk while in key-based dependency, you depend on another cached item.
Differentiate between globalization and localization.
– 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 while in localization you try to configure a Web application so that it can be supported for a specific language or locale.
Differentiate between a page theme and a global theme?
– Page theme applies to a particular web pages of the project. It is stored inside a subfolder of the App_Themes folder.
– Global theme applies to all the web applications on the web server. It is stored inside the Themes folder on a Web server.
What are Web server controls in ASP.NET?
– These are the objects on ASP.NET pages that run when the Web page is requested.
– Some of these Web server controls, like button and text box, are similar to the HTML controls.
– Some controls exhibit complex behavior like the controls used to connect to data sources and display data.

Q. 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.
How do Cookies work? Give an example of their abuse.
– The server directs the browser to put some files in a cookie. All the cookies are then sent for the domain in each request.
– An example of cookie abuse could be a case where a large cookie is stored affecting the network traffic.

Q. What are Custom User Controls in ASP.NET?
– These are the controls defined by developers and work similar to other web server controls.
– They are a mixture of custom behavior and predefined behavior.

Q. What is Role-based security?
– Used in almost all organization, the Role-based security assign 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 is able to do only what he is permitted to do on the system.

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

Q. What are the various types of Cookies in ASP.NET?
There exist two types of cookies in ASP.NET

1. Session Cookie
It resides on the machine of the client for a single session and works until the user logs out of the session.

2. Persistent Cookie
It resides on the machine of a user for a specified period. This period can be set up manually by the user.

Q. How would you turn off cookies on one page of your website?
– This can be done by using 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.

Q. How would you create a permanent cookie?
– Permanent cookies are stored on the hard disk and are available until a specified expiration date is reached.
– To create a cookie that never expires set its Expires property equal to DateTime.maxValue.
Explain Culture and UICulture values.
– Culture value determines the functions like Date and Currency used to format data and numbers in a Web page.
– UICulture value determines the resources like strings or images loaded in a Web application for a Web page.

Q. What is Global.asax file used for?
It executes application-level events and sets application-level variables.
Explain ASP.NET Web Forms.
– Web Forms are an extremely important part of ASP.NET.
– They are the User Interface (UI) elements which provide the desired look and feel to your web applications.
– Web Forms provide properties, methods, and events for the controls that are placed onto them.

Q. What is event bubbling?
– When child control send 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.

Q. What is RedirectPermanent in ASP.Net?

The RedirectPermanent(String) method overload gives a 301 HTTP status code in the reaction and incorporates the URL to divert the request. A 301 HTTP status code is a standard code in an HTTP reaction. It shows that a lasting redirection exists, and it gives the redirection area.

Q. What is ASP.NET Core?

ASP.NET Core is the open-source version of ASP.NET, that can be run on macOS, Linux, and Windows. ASP.NET Core was first delivered in 2016 and is a re-plan of prior Windows-just forms of ASP.NET.

In November 2015, Microsoft released the 5.0 version of ASP.NET which get separated later and known as ASP.NET Core. Also, it is considered as an important redesign of ASP.NET with the feature of open-source and cross-platform. Before this version, ASP.NET is only considered a Windows-only version.

Q. What is AJAX in ASP.NET?

The full form of ASP.NET AJAX is Asynchronous JavaScript and XML. ASP.NET AJAX also known as AJAX, is a bunch of augmentations of ASP.NET. It uses asynchronous data transfer between browser and webserver to allow web pages to request small bits of information from the server instead of entire pages. This technique makes Internet applications smaller, faster, and more user-friendly. It is created by Microsoft to execute AJAX functionalities in Web applications. The ASP.NET AJAX works with the AJAX Library that utilization object-arranged programming (OOP) to faster rich Web applications.

Q. What is Round Trip in ASP.NET?

At the point when server-side processing is included, then there are four stages included:

A user requests a Web form from the Web server.
Web Server reacts back with the mentioned Web form.
The user enters the information and submits the webform to the webserver.
Then Web Server processes the form structure and sends the outcomes back to the particular user.
Now, stage 3 is known as a page postback, while stages 3 and 4 are aggregately known as a “roundtrip”. We can say that- “A roundtrip includes making a total excursion over the network to the Web browser and getting the reaction back. The Web applications use HTTP to build up correspondence between the Web program and the Web server.

Q. What is Razor in ASP.NET?

In ASP.NET, Razor provides the syntax for developing dynamic web pages with the help of C# and HTML. ASP.NET can be integrated with JS(JavaScript) and it also includes the frameworks like React and Angular for the SPA(Single Page Application.)

Q. What is the REST architecture?

REST stands for REpresentational State Transfer.REST is an architectural style that doesn’t follow any strict standard but follows six constraints defined by Roy Fielding in 2000. Those constraints are – Uniform Interface, Client-Server, Stateless, Cacheable, Layered System, Code on Demand.REST is not restricted to XML and it’s the choice of implementer which Media-Type to use like XML, JSON, Plain-text. Moreover, REST can use SOAP protocol but SOAP cannot use REST.REST is easy to implement and requires less bandwidth such as smartphones.

Architectural Constraints of RESTful API: There are six architectural constraints that make any web service are listed below:

Uniform Interface
Layered System
Code on Demand
Q. What are the types of Authentication in ASP.NET?

Authentication is the process of checking the identity of a user based on the user’s credentials. Generally, user’s credentials are in the form of user ID and password, and we check their credentials from a database or equivalent alternative if it exists then the user is a valid candidate for the next process – authorization. There are different types of Authentication available in ASP.NET namely:

Form Authentication
Passport Authentication
Windows Authentication
Custom Authentication
Q. What is Caching and its different types?

In Asp.Net the caching method allows to store or cache Web Page output. This technic is used to avoiding the overhead of recreating the same data. There are three different caching types available in ASP.NET:

Page Output Caching
Page Fragment Caching
Data Caching
Caching increases the performance parameter if the same data or information is requested by the user.

Page Output Caching: It is implemented by placing an OutputCache directive at the top of the .aspx page at design time.
Data Caching: It is used for quick retrieval of application data and implemented by the Cache object.
Page Fragment Caching: It is used to store part of a Web form response in memory by caching a user control.
Q. What is Query String in ASP? And what are its advantages and disadvantages?

A QueryString is a collection of characters input to a computer web browser. It is helpful when we want to transfer a value from one page to another page. If the sending data is in large quantity then we can not use Request.QueryString because it supports only 255 characters. We use the ‘&’ special character for separate multiple query strings. Any query string that was available to the calling ASPX page will be available to the called ASPX page.

Q. What does the method Finalize do in ASP.NET?

The Finalize technique is utilized to perform a cleanup procedure on unmanaged resources held by the current object before the object is destroyed. The strategy is ensured and subsequently is available just through this class or through a derived class.

Q. Write down the name of all steps in the ASP.NET page life cycle?

Page request
Starting of page life cycle
Page initialization
Page Load
Postback event handling
Page rendering
Q. Briefly describe the difference between the Web Site and Web Application?

A web application is a piece of software that can be accessed by the browser. A Browser is an application that is used to browse the internet. Web application needs authentication. The web application uses a combination of server-side scripts and client-side scripts to present information. It requires a server to manage requests from the users. For example, Google Apps

A website is a collection of related web pages that contains images, text, audio, video, etc. It can be consist of one page, two pages, and n number of pages. A website provides visual and text content that users can view and read. To view a website requires a browser(chrome, firefox). There are many types of websites like Archive website, Blog, Community website, Dating website, etc. For example, Amazon, youtube, etc.

For more  Click Here