We are going to share with you the top 10 interview questions and answers in ASP.NET/MVC for your preparation purpose:
1- What is MVC
Model–view–controller (MVC) is a software design pattern for implementing user interfaces on computers. It divides a given software application into three interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user.
As an ASP.NET MVC is a framework for building web applications using a MVC (Model View Controller) design pattern:
- A Model , which represents the underlying, logical structure of data in a software application and the high-level class associated with it. This object model does not contain any information about the user interface.
- A View , which is a collection of classes representing the elements in the user interface (all of the things the user can see and respond to on the screen, such as buttons, display boxes, and so forth)
For more information about how to build MCV application visit this website
2- What are routs in MVC and where to configure it?
Routing is a way to process the incoming url that is more descriptive and give desired response. A route is a URL pattern that is mapped to a handler. The handler can be a physical file, such as a .aspx file in a Web Forms application. A handler can also be a class that processes the request, such as a controller in an MVC application. To define a route, you create an instance of the Route class by specifying the URL pattern, the handler, and optionally a name for the route.
3- What Are Action Filters in MVC?
Action Filters: Action filters are used to implement logic that gets executed before and after a controller action executes.
4- What is Razor Engine and how it works?
Razor ia an ASP MVC view engine that lets you to write server-based code in your view to create a dynamic content the render it into availd HTML
5- Mention three ways to pass data between the controllers and views, and when to use each of them?
ViewData: It is available for the current request only and requires typecasting for complex data type.
ViewBag: Dynamic property that takes advantage of the new dynamic features in C# 4.0, also available for the current request only. If redirection occurs, then its value becomes null and doesn’t require typecasting for complex data type.
TempData: used to pass data from the current request to the next request, keeps the information for the time of an HTTP Request. This means only from one page to another.
6- What are HTML Helpers and why to use it?
HtmlHelper class generates html elements using the model class object in razor view. It binds the model object to html elements to display value of model properties into html elements and also assigns the value of the html elements to the model properties while submitting web form. So always use HtmlHelper class in razor view instead of writing html tags manually.
7- What is RESTfull APIs?
REST stands for REpresentational State Transfer. REST is web standards based architecture and uses HTTP Protocol for data communication. It revolves around resource where every component is a resource and a resource is accessed by a common interface using HTTP standard methods
In REST architecture, a REST Server simply provides access to resources and REST client accesses and presents the resources. Here each resource is identified by URIs/ global IDs. REST uses various representations to represent a resource like text, JSON and XML. Now a days JSON is the most popular format being used in web services.
8- What is Output Caching in MVC?
It enables us to cache the content returned by any controller method so that the same content does not need to be generated each time the same controller method is invoked. Output Caching has huge advantages, such as it reduces server round trips, reduces database server round trips, reduces network traffic etc. The main purpose of using Output Caching is to improve the performance of the application.
9- What is Bundling and Minification in MVC?
Bundling and minification are two techniques you can use to improve request load time.
Bundling helps you to download files of same type using one request instead of multiple requests. This way you can download styles and scripts using less requests than it takes to request all files separately.
Minification performs a variety of different code optimizations to scripts or css, such as removing unnecessary white space,comments and shortening variable names to one character.
10What is Partial View in MVC?
A partial view is a component built by the developer to re-use a bulk of HTML that can be inserted into an existing DOM. Most commonly, partial views are used to componentize Razor views and make them easier to build and update. Partial views can also be returned directly from controller methods.