Q :- What are the 3 main components of an ASP.NET MVC application?ANS : 1. M - Model 2. V - View 3. C - ControllerQ :- In which assembly is the MVC framework defined?ANS : System.Web.MvcQ :- Is it possible to combine ASP.NET webforms and ASP.MVC and develop a single web application?ANS : Yes, it is possible to combine ASP.NET webforms and ASP.MVC and develop a single web application.Q :- What does Model, View and Controller represent in an MVC application?ANS :Model: Model represents the application data domain. In short the applications business logic is contained with in the model.View: Views represent the user interface, with which the end users interact. In short the all the user interface logic is contained with in the UI.Controller: Controller is the component that responds to user actions. Based on the user actions, the respective controller, work with the model, and selects a view to render that displays the user interface. The user input logic is contained with in the controller.What is the greatest advantage of using asp.net mvc over asp.net webforms?ANS : It is difficult to unit test UI with webforms, where views in mvc can be very easily unit tested.Q :- Which approach provides better support for test driven development - ASP.NET MVC or ASP.NET Webforms?ANS : ASP.NET MVCQ :- What are the advantages of ASP.NET MVC?ANS :1. Extensive support for TDD. With asp.net MVC, views can also be very easily unit tested.2. Complex applications can be easily managed3. Seperation of concerns. Different aspects of the application can be divided into Model, View and Controller.4. ASP.NET MVC views are light weight, as they donot use viewstate.Q :- Is it possible to unit test an MVC application without running the controllers in an ASP.NET process?ANS : Yes, all the features in an asp.net MVC application are interface based and hence mocking is much easier. So, we don't have to run the controllers in an ASP.NET process for unit testing.Q :- Is it possible to share a view across multiple controllers?ANS : Yes, put the view into the shared folder. This will automatically make the view available across multiple controllers.Q :- What is the role of a controller in an MVC application?ANS : The controller responds to user interactions, with the application, by selecting the action method to execute and alse selecting the view to render.Q :- Where are the routing rules defined in an asp.net MVC application?ANS : In Application_Start event in Global.asaxQ :- Name a few different return types of a controller action method?ANS :The following are just a few return types of a controller action method. In general an action method can return an instance of a any class that derives from ActionResult class.1. ViewResult2. JavaScriptResult3. RedirectResult4. ContentResult5. JsonResultQ :- What is the significance of NonActionAttribute?ANS : In general, all public methods of a controller class are treated as action methods. If you want prevent this default behaviour, just decorate the public method with NonActionAttribute.Q :- What is the significance of ASP.NET routing?ANS : ASP.NET MVC uses ASP.NET routing, to map incoming browser requests to controller action methods. ASP.NET Routing makes use of route table. Route table is created when your web application first starts. The route table is present in the Global.asax file.Q :- What are the 3 segments of the default route, that is present in an ASP.NET MVC application?ANS : 1st Segment - Controller Name2nd Segment - Action Method Name3rd Segment - Parameter that is passed to the action methodExample: http://pragimtech.com/Customer/Details/5Controller Name = CustomerAction Method Name = DetailsParameter Id = 5Q :- ASP.NET MVC application, makes use of settings at 2 places for routing to work correctly. What are these 2 places?ANS :1. Web.Config File : ASP.NET routing has to be enabled here.2. Global.asax File : The Route table is created in the application Start event handler, of the Global.asax file.Q :- What is the adavantage of using ASP.NET routing?ANS : In an ASP.NET web application that does not make use of routing, an incoming browser request should map to a physical file. If the file does not exist, we get page not found error.An ASP.NET web application that does make use of routing, makes use of URLs that do not have to map to specific files in a Web site. Because the URL does not have to map to a file, you can use URLs that are descriptive of the user's action and therefore are more easily understood by users.Q :- What are the 3 things that are needed to specify a route?ANS :1. URL Pattern - You can include placeholders in a URL pattern so that variable data can be passed to the request handler without requiring a query string.2. Handler - The handler can be a physical file such as an .aspx file or a controller class.3. Name for the Route - Name is optional.Q :- Is the following route definition a valid route definition?{controller}{action}/{id}ANS : No, the above definition is not a valid route definition, because there is no literal value or delimiter between the placeholders. Therefore, routing cannot determine where to separate the value for the controller placeholder from the value for the action placeholder.Q :- What is the use of the following default route?{resource}.axd/{*pathInfo}ANS : This route definition, prevent requests for the Web resource files such as WebResource.axd or ScriptResource.axd from being passed to a controller.Q :- What is the difference between adding routes, to a webforms application and to an mvc application?ANS : To add routes to a webforms application, we use MapPageRoute() method of the RouteCollection class, where as to add routes to an MVC application we use MapRoute() method.Q :- How do you handle variable number of segments in a route definition?ANS : Use a route with a catch-all parameter. An example is shown below. * is referred to as catch-all parameter.controller/{action}/{*parametervalues}Q :- What are the 2 ways of adding constraints to a route?ANS :1. Use regular expressions2. Use an object that implements IRouteConstraint interfaceQ :- Give 2 examples for scenarios when routing is not applied?ANS :1. A Physical File is Found that Matches the URL Pattern - This default behaviour can be overriden by setting the RouteExistingFiles property of the RouteCollection object to true.2. Routing Is Explicitly Disabled for a URL Pattern - Use the RouteCollection.Ignore() method to prevent routing from handling certain requests.Q :- What is the use of action filters in an MVC application?ANS : Action Filters allow us to add pre-action and post-action behavior to controller action methods.Q :- If I have multiple filters impleted, what is the order in which these filters get executed?ANS :1. Authorization filters2. Action filters3. Response filters4. Exception filtersQ :- What are the different types of filters, in an asp.net mvc application?ANS :1. Authorization filters2. Action filters3. Result filters4. Exception filtersQ :- Give an example for Authorization filters in an asp.net mvc application?ANS :1. RequireHttpsAttribute2. AuthorizeAttributeQ :- Which filter executes first in an asp.net mvc application?ANS : Authorization filterQ :- What are the levels at which filters can be applied in an asp.net mvc application?ANS :1. Action Method2. Controller3. ApplicationQ :- Is it possible to create a custom filter?ANS : YesQ :- What filters are executed in the end?ANS : Exception FiltersQ :- Is it possible to cancel filter execution?ANS : YesQ :- What type of filter does OutputCacheAttribute class represents?ANS : Result FilterQ :- What are the 2 popular asp.net mvc view engines?ANS :1. Razor2. .aspxQ :- What symbol would you use to denote, the start of a code block in razor views?ANS : @Q :- What symbol would you use to denote, the start of a code block in aspx views?ANS : <%= %>Q :- In razor syntax, what is the escape sequence character for @ symbol?ANS : The escape sequence character for @ symbol, is another @ symbolQ :- When using razor views, do you have to take any special steps to proctect your asp.net mvc application from cross site scripting (XSS) attacks?ANS : No, by default content emitted using a @ block is automatically HTML encoded to protect from cross site scripting (XSS) attacks.Q :- When using aspx view engine, to have a consistent look and feel, across all pages of the application, we can make use of asp.net master pages. What is asp.net master pages equivalent, when using razor views?ANS : To have a consistent look and feel when using razor views, we can make use of layout pages. Layout pages, reside in the shared folder, and are named as _Layout.cshtmlQ :- What are sections?ANS : Layout pages, can define sections, which can then be overriden by specific views making use of the layout. Defining and overriding sections is optional.Q :- What are the file extensions for razor views?ANS :1. .cshtml - If the programming lanugaue is C#2. .vbhtml - If the programming lanugaue is VBQ :- How do you specify comments using razor syntax?ANS : Razor syntax makes use of @* to indicate the begining of a comment and *@ to indicate the end. An example is shown below.@* This is a Comment *@Also refer more important questions on Data Annotations in MVC3link