Asp Net Mvc Interview Questions And Answers

Asp Net Mvc Interview Questions list for experienced

  1. What is MVC (Model View Controller)?
  2. Explain MVC application life cycle?
  3. Is MVC suitable for both Windows and Web applications?
  4. What are the benefits of using MVC?
  5. Is MVC different from a three layered architecture?
  6. What is the latest version of MVC?
  7. What is the difference between each version of MVC 2, 3 , 4, 5 and 6?
  8. What are HTML helpers in MVC?
  9. What is the difference between "HTML.TextBox" vs "HTML.TextBoxFor"?
  10. What is routing in MVC?
  11. Where is the route mapping code written?
  12. Can we map multiple URL's to the same action?
  13. Explain attribute based routing in MVC?
  14. How can we navigate from one view to another using a hyperlink?
  15. How can we restrict MVC actions to be invoked only by GET or POST?
  16. How can we maintain sessions in MVC?
  17. What is the difference between tempdata, viewdata, and viewbag?
  18. What is difference between TempData and ViewData ?
  19. Does "TempData" preserve data in the next request also?
  20. What is the use of Keep and Peek in "TempData"?
  21. What are partial views in MVC?
  22. How did you create a partial view and consume it?
  23. How can we do validations in MVC?
  24. Can we display all errors in one go?
  25. How can we enable data annotation validation on client side?
  26. What is Razor in MVC?
  27. Why Razor when we already have ASPX?
  28. So which is a better fit, Razor or ASPX?
  29. How can you do authentication and authorization in MVC?
  30. How to implement Windows authentication for MVC?
  31. How do you implement Forms authentication in MVC?
  32. How to implement AJAX in MVC?
  33. What is the difference between ActionResult and ViewResult?
  34. What are the different types of results in MVC?
  35. What are ActionFilters in MVC?
  36. Can we create our custom view engine using MVC?
  37. How to send result back in JSON format in MVC
  38. What is WebAPI?
  39. But WCF SOAP also does the same thing, so how does WebAPI differ?
  40. With WCF you can implement REST, so why WebAPI?
  41. How to implement WebAPI in MVC
  42. How can we detect that an MVC controller is called by POST or GET?
  43. What is bundling and minification in MVC?
  44. How does bundling increase performance?
  45. So how do we implement bundling in MVC?
  46. How can you test bundling in debug mode?
  47. Explain minification and how to implement it
  48. How do we implement minification?
  49. Explain Areas in MVC?
  50. Explain the concept of View Model in MVC?
  51. What kind of logic view model class will have?
  52. How can we use two ( multiple) models with a single view?
  53. Explain the need of display mode in MVC?
  54. Explain MVC model binders?
  55. Explain the concept of MVC Scaffolding?
  56. What does scaffolding use internally to connect to database?
  57. How can we do exception handling in MVC?
  58. How can you handle multiple Submit buttons pointing to multiple actions in a single MVC view?

Asp Net Mvc interview questions and answers on advance and basic Asp Net Mvc with example so this page for both freshers and experienced condidate. Fill the form below we will send the all interview questions on Asp Net Mvc also add your Questions if any you have to ask and for apply in Asp Net Mvc Tutorials and Training course just send a mail on info@pcds.co.in in detail about your self.

Top Asp Net Mvc interview questions and answers for freshers and experienced

What is Asp Net Mvc ?

Answer : The ASP.NET MVC Framework is an open source web application framework and tooling that implements a version of the model-view-controller (MVC) pattern tailored towards web applications and built upon an ASP.NET technology foundation

Questions : 1 :: What is MVC (Model View Controller)?

MVC is an architectural pattern which separates the representation and user interaction. It’s divided into three broader sections, Model, View, and Controller. Below is how each one of them...View answers

Questions : 2 :: Explain MVC application life cycle?

There are six broader events which occur in MVC application life cycle below diagrams summarize it.   Any web application has two main execution steps first understanding the request and...View answers

Questions : 3 :: Is MVC suitable for both Windows and Web applications?


The MVC architecture is suited for a web application than Windows. For Window applications, MVP, i.e., “Model View Presenter” is more applicable. If you are using WPF and Silverlight,...View answers

Questions : 4 :: What are the benefits of using MVC?

There are two big benefits of MVC: Separation of concerns is achieved as we are moving the code-behind to a separate class file. By moving the binding code to a separate class file we can reuse...View answers

Questions : 5 :: Is MVC different from a three layered architecture?

MVC is an evolution of a three layered traditional architecture. Many components of the three layered architecture are part of MVC. So below is how the mapping goes: Functionality Three...View answers

Questions : 6 :: What is the latest version of MVC?


MVC 6 is the latest version which is also termed as ASP VNEXT.

Questions : 7 :: What is the difference between each version of MVC 2, 3 , 4, 5 and 6?

MVC 6 ASP.NET MVC and Web API has been merged in to one. Dependency injection is inbuilt and part of MVC. Side by side - deploy the runtime and framework with your application Everything packaged...View answers

Questions : 8 :: What are HTML helpers in MVC?

HTML helpers help you to render HTML controls in the view. For instance if you want to display a HTML textbox on the view , below is the HTML helper code. <%= Html.TextBox("LastName")...View answers

Questions : 9 :: What is the difference between "HTML.TextBox" vs "HTML.TextBoxFor"?


Both of them provide the same HTML output, “HTML.TextBoxFor” is strongly typed while “HTML.TextBox” isn’t. Below is a simple HTML code which just creates a simple...View answers

Questions : 10 :: What is routing in MVC?

Routing helps you to define a URL structure and map the URL with the controller. For instance let’s say we want that when a user types “http://localhost/View/ViewCustomer/”, it...View answers

Questions : 11 :: Where is the route mapping code written?

The route mapping code is written in "RouteConfig.cs" file and registered using "global.asax" application start event.

Questions : 12 :: Can we map multiple URL's to the same action?

Yes, you can, you just need to make two entries with different key names and specify the same controller and action.

Questions : 13 :: Explain attribute based routing in MVC?

This is a feature introduced in MVC 5. By using the "Route" attribute we can define the URL structure. For example in the below code we have decorated the "GotoAbout" action with the route...View answers

Questions : 14 :: How can we navigate from one view to another using a hyperlink?

By using the ActionLink method as shown in the below code. The below code will create a simple URL which helps to navigate to the “Home” controller and invoke the GotoHome action. Hide...View answers

Questions : 15 :: How can we restrict MVC actions to be invoked only by GET or POST?

We can decorate the MVC action with the HttpGet or HttpPost attribute to restrict the type of HTTP calls. For instance you can see in the below code snippet the DisplayCustomer action can only be...View answers

Questions : 16 :: How can we maintain sessions in MVC?

Sessions can be maintained in MVC by three ways: tempdata, viewdata, and viewbag.

Questions : 17 :: What is the difference between tempdata, viewdata, and viewbag?

Figure: Difference between tempdata, viewdata, and viewbag Temp data - Helps to maintain data when you move from one controller to another controller or from one action to another action. In...View answers

Questions : 18 :: What is difference between TempData and ViewData ?

"TempData" maintains data for the complete request while "ViewData" maintains data only from Controller to the view.

Questions : 19 :: Does "TempData" preserve data in the next request also?

“TempData” is available through out for the current request and in the subsequent request it’s available depending on whether “TempData” is read or not. So if...View answers

Questions : 20 :: What is the use of Keep and Peek in "TempData"?

Once “TempData” is read in the current request it’s not available in the subsequent request. If we want “TempData” to be read and also available in the subsequent...View answers

Questions : 21 :: What are partial views in MVC?

Partial view is a reusable view (like a user control) which can be embedded inside other view. For example let’s say all your pages of your site have a standard structure with left menu,...View answers

Questions : 22 :: How did you create a partial view and consume it?

When you add a view to your project you need to check the “Create partial view” check box. Figure: Create partial view Once the partial view is created you can then call the partial...View answers

Questions : 23 :: How can we do validations in MVC?

One of the easiest ways of doing validation in MVC is by using data annotations. Data annotations are nothing but attributes which can be applied on model properties. For example, in the below code...View answers

Questions : 24 :: Can we display all errors in one go?

Yes, we can; use the ValidationSummary method from the Html helper class. Hide   Copy Code <%= Html.ValidationSummary() %> What are the other data annotation attributes for...View answers

Questions : 25 :: How can we enable data annotation validation on client side?

It’s a two-step process: first reference the necessary jQuery files. Hide   Copy Code <script src="<%= Url.Content("~/Scripts/jquery-1.5.1.js") %>"...View answers

Questions : 26 :: What is Razor in MVC?

It’s a light weight view engine. Till MVC we had only one view type, i.e., ASPX. Razor was introduced in MVC 3.

Questions : 27 :: Why Razor when we already have ASPX?

Razor is clean, lightweight, and syntaxes are easy as compared to ASPX. For example, in ASPX to display simple time, we need to write: Hide   Copy Code <%=DateTime.Now%> In Razor,...View answers

Questions : 28 :: So which is a better fit, Razor or ASPX?

As per Microsoft, Razor is more preferred because it’s light weight and has simple syntaxes.

Questions : 29 :: How can you do authentication and authorization in MVC?

You can use Windows or Forms authentication for MVC.

Questions : 30 :: How to implement Windows authentication for MVC?

For Windows authentication you need to modify the web.config file and set the authentication mode to Windows. Hide   Copy Code <authentication...View answers

Questions : 31 :: How do you implement Forms authentication in MVC?

Forms authentication is implemented the same way as in ASP.NET. The first step is to set the authentication mode equal to Forms. The loginUrl points to a controller here rather than a page. Hide...View answers

Questions : 32 :: How to implement AJAX in MVC?

You can implement AJAX in two ways in MVC: AJAX libraries jQuery Below is a simple sample of how to implement AJAX by using the “AJAX” helper library. In the below code you can see...View answers

Questions : 33 :: What is the difference between ActionResult and ViewResult?

ActionResult is an abstract class while ViewResult derives from the ActionResult class. ActionResult has several derived classes like ViewResult, JsonResult, FileStreamResult, and so...View answers

Questions : 34 :: What are the different types of results in MVC?

Note: It’s difficult to remember all the 12 types. But some important ones you can remember for the interview are ActionResult, ViewResult, and JsonResult. Below is a detailed list for your...View answers

Questions : 35 :: What are ActionFilters in MVC?

ActionFilters help you to perform logic while an MVC action is executing or after an MVC action has executed. Figure: ActionFilters in MVC Action filters are useful in the following...View answers

Questions : 36 :: Can we create our custom view engine using MVC?

Yes, we can create our own custom view engine in MVC. To create our own custom view engine we need to follow three steps: Let’ say we want to create a custom view engine where in the user can...View answers

Questions : 37 :: How to send result back in JSON format in MVC

In MVC, we have the JsonResult class by which we can return back data in JSON format. Below is a simple sample code which returns back a Customer object in JSON format using JsonResult. Hide  ...View answers

Questions : 38 :: What is WebAPI?

HTTP is the most used protocol. For the past many years, browser was the most preferred client by which we consumed data exposed over HTTP. But as years passed by, client variety started spreading...View answers

Questions : 39 :: But WCF SOAP also does the same thing, so how does WebAPI differ?

  SOAP WEB API Size Heavy weight because of complicated WSDL structure. Light weight, only the necessary information is transferred. Protocol Independent of...View answers

Questions : 40 :: With WCF you can implement REST, so why WebAPI?

WCF was brought into implement SOA, the intention was never to implement REST. WebAPI is built from scratch and the only goal is to create HTTP services using REST. Due to the one point focus for...View answers

Questions : 41 :: How to implement WebAPI in MVC

Below are the steps to implement WebAPI: Step 1: Create the project using the WebAPI template. Figure: Implement WebAPI in MVC Step 2: Once you have created the project you will notice that the...View answers

Questions : 42 :: How can we detect that an MVC controller is called by POST or GET?

To detect if the call on the controller is a POST action or a GET action we can use the Request.HttpMethod property as shown in the below code snippet. Hide   Copy Code public ActionResult...View answers

Questions : 43 :: What is bundling and minification in MVC?

Bundling and minification helps us improve request load times of a page thus increasing performance.

Questions : 44 :: How does bundling increase performance?

Web projects always need CSS and script files. Bundling helps us combine multiple JavaScript and CSS files in to a single entity thus minimizing multiple requests in to a single request. For example...View answers

Questions : 45 :: So how do we implement bundling in MVC?

Open BundleConfig.cs from the App_Start folder. In BundleConfig.cs, add the JS files you want bundle into a single entity in to the bundles collection. In the below code we are combining all the...View answers

Questions : 46 :: How can you test bundling in debug mode?

If you are in a debug mode you need to set EnableOptimizations to true in the bundleconfig.cs file or else you will not see the bundling effect in the page...View answers

Questions : 47 :: Explain minification and how to implement it

Minification reduces the size of script and CSS files by removing blank spaces , comments etc. For example below is a simple javascript code with comments. // This is test var x = 0; x = x + 1; x...View answers

Questions : 48 :: How do we implement minification?

When you implement bundling, minification is implemented by itself. In other words the steps to implement bundling and minification are the same.

Questions : 49 :: Explain Areas in MVC?

Areas help you to group functionalities in to independent modules thus making your project more organized. For example in the below MVC project we have four controller classes and as time passes by...View answers

Questions : 50 :: Explain the concept of View Model in MVC?

A view model is a simple class which represents data to be displayed on the view. For example below is a simple customermodel object with “CustomerName” and “Amount”...View answers

Questions : 51 :: What kind of logic view model class will have?

As the name says view model this class has the gel code or connection code which connects the view and the model. So the view model class can have following kind of logics:- Color transformation...View answers

Questions : 52 :: How can we use two ( multiple) models with a single view?

Let us first try to understand what the interviewer is asking. When we bind a model with a view we use the model dropdown as shown in the below figure. In the below figure we can only select one...View answers

Questions : 53 :: Explain the need of display mode in MVC?

Display mode displays views depending on the device the user has logged in with. So we can create different views for different devices anddisplay mode will handle the rest. For example we can...View answers

Questions : 54 :: Explain MVC model binders?

Model binder maps HTML form elements to the model. It acts like a bridge between HTML UI and MVC model. Many times HTML UI names are different than the model property names. So in the binder we can...View answers

Questions : 55 :: Explain the concept of MVC Scaffolding?

Note :- Do not get scared with the word. Its actually a very simple thing. Scaffolding is a technique in which the MVC template helps to auto-generate CRUD code. CRUD stands for create, read, update...View answers

Questions : 56 :: What does scaffolding use internally to connect to database?

It uses Entity framework internally.

Questions : 57 :: How can we do exception handling in MVC?

In the controller you can override the “OnException” event and set the “Result” to the view name which you want to invoke when error occurs. In the below code you can see we...View answers

Questions : 58 :: How can you handle multiple Submit buttons pointing to multiple actions in a single MVC view?

Let us elaborate on what the interviewer wants to ask because the above question is just a single liner and is not clear about what the interviewer wants. Take a scenario where you have a view with...View answers
More Question

Ask your interview questions on Asp Net Mvc

Write Your comment or Questions if you want the answers on Asp Net Mvc from Asp Net Mvc Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---