Skip to content

Desi banjara

  • Microsoft PL-900 Certification Exam Practice Questions – 1 PL-900: Microsoft Power Platform Fundamentals
  • “Fall seven times, stand up eight.”– Japanese Proverb Motivational & Inspirational Quotes
  • Microsoft Azure – Security, compliance and identity concepts Uncategorized
  • Travel Quotes – Adventure is worthwhile- Aesop Travel Quotes
  • Diwali 2020 Wishes, SMS Messages, WhatsApp Messages & Quotes Best Wishes Messages
  • Happy birthday to my mom and thank you for everything you’ve done for me and my kids. I don’t know what I’d do without you. Thank you for teaching me to be respectful and caring adults. I couldn’t do it without you. Birthday Wishes For Mom
  • Top 20 beginner level C# interview questions C# development
  • Microsoft AI-900 Certification Exam Practice Questions -2 Microsoft AI-900 Certification Exam

ASP.Net MVC Interview Questions

Posted on September 9, 2018 By DesiBanjara No Comments on ASP.Net MVC Interview Questions

Interview Question 1: What is MVC?

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 handles the task.

  • The View is responsible for the look and feel. It is the presentation layer in MVC.
  • Model represents the real world object and provides data to the View.
  • The Controller is responsible for taking the end user request and loading the appropriate Model and View

Interview Question 2: What is ASP.NET MVC?

[amazon_textlink asin=’1430265299|1484221362′ text=’ASP.NET MVC’ template=’ProductLink’ store=’desibanjara22-21|desibanjaraco-21′ marketplace=’IN|UK’ link_id=’e8db020a-b46a-11e8-bb61-0b10f0770be6′] is a web application Framework based on the MVC architectural pattern. It is light weight and highly testable Framework. MVC separates application into three components — Model, View and Controller.

The MVC model also provides full control over HTML, CSS, and JavaScript.

The MVC separation helps developers to manage complex applications because we can focus on one aspect a time. For example, you can focus on the view without depending on the business logic. It also makes it easier to test an application.

Interview Question 3: What are the benefits of using MVC? Or

What are the advantages of MVC over ASP.NET?

There are two big benefits of MVC:

  • Provides a clean separation of concerns among UI (Presentation layer), model (Domain Objects/Entities) and Business Logic (Controller).
  • By moving the binding code to a separate class we can also reuse the code to a great extent. We can have multiple views which can point to the same model and vice versa.
  • Automated UI testing is possible because now the behind code (UI interaction code) has moved to a simple .NET class. This gives us opportunity to write unit tests and automate manual testing.
  • Improved structuring of the code.

Interview Question 4: Can you explain the page life cycle of MVC?

Below are the sequence of processes in ASP.NET MVC life cycle:-

  • App initialization
  • Routing
  • Instantiate and execute controller
  • Locate and invoke controller action
  • Instantiate and render view.

Interview Question 5: What is Razor View Engine?

Razor was the first major update to render HTML in MVC 3. Razor was designed specifically for view engine syntax. Main focus of Razor was to simplify and code-focused templating for HTML generation.

Interview Question 6: What is the meaning of Unobtrusive JavaScript?

This is a general term that conveys a general philosophy, similar to the term REST (Representational State Transfer). Unobtrusive JavaScript doesn’t intermix JavaScript code in your page markup.

Example: Instead of using events like onclick and onsubmit, the unobtrusive JavaScript attaches to elements by their ID or class based on the HTML5 data- attributes.

Interview Question 7: What is the use of ViewModel in MVC?

ViewModel is a plain class with properties, which is used to bind it to strongly typed view. ViewModel can have the validation rules defined for its properties using data annotations.

Interview Question 8: What are Actions in MVC?

Actions are the methods in Controller class which is responsible for returning the view or json data. Action will mainly have return type — “ActionResult” and it will be invoked from method — “InvokeAction()” called by controller.

Interview Question 9: How can we maintain sessions in MVC?

In MVC sessions can be maintained by three ways: tempdata, viewdata, and viewbag.

Interview Question 10: What is ViewData?

Viewdata contains the key, value pairs as dictionary and this is derived from class — “ViewDataDictionary“. In action method we can set the value for viewdata and in view the value will be fetched by typecasting.

Viewdata maintain state between controller and corresponding view. Just only for single request. It will become null in further request or if redirect occurs.

Interview Question 11: What is the difference between ViewBag and ViewData in MVC?

ViewBag is a wrapper around ViewData, which allows to create dynamic properties. Advantage of viewbag over viewdata will be –

In ViewBag no need to typecast the objects as in ViewData.

ViewBag will take advantage of dynamic keyword which is introduced in version 4.0. But before using ViewBag we have to keep in mind that ViewBag is slower than ViewData.

Interview Question 12: Explain TempData in MVC?

TempData is again a key, value pair as ViewData. This is derived from “TempDataDictionary” class. TempData is used when the data is to be used in two consecutive requests, this could be between the actions or between the controllers. This requires typecasting in view.

[amazon_link asins=’B00TQXRQKY|1788293606′ template=’ProductAd’ store=’desibanjara22-21|desibanjaraco-21′ marketplace=’IN|UK’ link_id=’40c039e2-b46b-11e8-8159-394253d23a30′]

Interview Question 13: 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.

Interview Question 14: What you mean by Routing in MVC?

Routing is a pattern matching mechanism of incoming requests to the URL patterns which are registered in route table.

Interview Question 15: What is Attribute Routing in MVC?

Attribute Routing is introduced in MVC5. ASP.NET Web API also supports this type routing. In this type of routing, attributes are being used to define the routes. This type of routing gives more control over classic URI Routing. Attribute Routing can be defined at controller level or at Action level.

Interview Question 16: How to enable Attribute Routing?

Just add the method — “MapMvcAttributeRoutes()” to enable attribute routing as shown below

public static void RegistearRoutes(RouteCollection routes)

{

routes.IgnoareRoute(“{resource}.axd/{*pathInfo}”);

//enabling attribute routing

routes.MapMvcAttributeRoutes();

//convention-based routing

routes.MapRoute

(

name: “Default”,

url: “{controller}/{action}/{id}”,

defaults: new { controller = “Customer”, action = “GetCustomerList”, id = UrlParameter.Optional }

);

}

Interview Question 17: Explain JSON Binding?

JavaScript Object Notation (JSON) binding support started from MVC3 onwards via the new JsonValueProviderFactory, which allows the action methods to accept and model-bind data in JSON format. This is useful in Ajax scenarios like client templates and data binding that need to post data back to the server.

Interview Question 18: How to send result back in JSON format in MVC?

JsonResult class by which we can return back data in JSON format.

Interview Question 19: Explain Bundle.Config in MVC4?

“BundleConfig.cs” in MVC4 is used to register the bundles by the bundling and minification system. Many bundles are added by default including jQuery libraries like — jquery.validate, Modernizr, and default CSS references.

Interview Question 20: What are HTML helpers in MVC? 

HTML Helpers are like controls in traditional web forms. It help you to render HTML controls in the view. But HTML helpers are more lightweight compared to web controls as it does not hold viewstate and events.

HTML Helpers returns the HTML string which can be directly rendered to HTML page. Custom HTML Helpers also can be created by overriding “HtmlHelper” class.

Interview Question 21: What is the difference between “HTML.TextBox” vs “HTML.TextBoxFor”?

HTML.TextBoxFor” is strongly typed while “HTML.TextBox” isn’t.

[amazon_link asins=’1430265299,B00SWFNGOW,9352130936,B01IF63FIY,8183335810,1786463830,8126551925,9350041995,B00TQXRQKY|1484221362,1118794753,1788476638,148423149X,1430265299,1788293606,1430265418,1535167866,1546832068′ template=’ProductGrid’ store=’desibanjara22-21|desibanjaraco-21′ marketplace=’IN|UK’ link_id=’dabc816c-b46a-11e8-8330-fb8992d8449c’]

ASP.Net MVC, Interview questions, IT/Software development Tags:ASP.Net MVC, Interview questions

Post navigation

Previous Post: Object Oriented Programming (OOP) in C#
Next Post: Happy Halloween Wishes, Sayings, Quotes and Messages

Related Posts

  • Top 20 GIT Interview Questions GIT
  • How to enable cors in WebApi to handle request from different subdomains? ASP.NET Web API
  • C# interview Questions – What is struct in C#? C# development
  • Interview question: What are the two types of data type in C#? C# development
  • Interview question: Which class acts as a base class for all arrays in C#? C# development
  • Interview question: What is the purpose of an access specifier in C#? C# development

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *



Archives

  • February 2023
  • February 2022
  • June 2021
  • March 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • July 2020
  • June 2020
  • April 2020
  • December 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • January 2018
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • August 2015
  • May 2015
  • April 2014
  • November 2013

Categories

  • Acer
  • Amazon AWS Certification Exam
  • Amazon Kindle
  • Android phones
  • ASP.Net MVC
  • ASP.NET Web API
  • AWS DevOps Engineer Professional Exam
  • AZ-300: Microsoft Azure Architect Technologies Exam
  • Azure Active Directory
  • Azure App Services
  • Azure Data Factory
  • Azure Logic Apps
  • Azure Mobile Apps
  • Azure Virtual Machine
  • Best Wishes Messages
  • birthday messages for boyfriend
  • Birthday messages For Girlfriend
  • Birthday Wishes
  • Birthday Wishes For Mom
  • Business
  • C# development
  • Cameras
  • Canon
  • Cloud
  • Cloud services
  • digital-cameras
  • Diwali
  • Entrepreneurship
  • eReaders
  • Family Quotes
  • Family Quotes
  • Friendship Quotes
  • Gadgets
  • Games
  • Get Well Soon Messages
  • GIT
  • Good Morning Wishes
  • Google
  • Gratitude Quote
  • Guru Nanak Jayanti
  • Halloween
  • Happiness Quote
  • Happy Diwali Wishes
  • Happy Independence Day Wishes
  • Happy New Year Wishes
  • HTC
  • HTC One
  • HTML
  • I Miss You Messages
  • Inspirational Quotes
  • Inspirational Travel Quotes
  • Interview questions
  • IT/Software development
  • Leadership Quote
  • Life lessons
  • Love Quotes
  • Love shayari
  • Messages
  • Microsoft AI-900 Certification Exam
  • Microsoft AZ-104 Certification Exam
  • Microsoft AZ-204 Certification Exam
  • Microsoft AZ-900 Certification Exam
  • Microsoft Azure
  • Microsoft Azure certifications
  • Microsoft Exam AZ-220
  • Microsoft Excel
  • Microsoft Office
  • Microsoft word
  • Mobile phones
  • Motivational & Inspirational Quotes
  • Nature Quotes
  • Nexus
  • Nikon
  • Pixels
  • PL-200: Microsoft Power Platform Functional Consultant Certification
  • PL-900: Microsoft Power Platform Fundamentals
  • postman
  • Quotes
  • Robin Sharma
  • Samsung Galaxy S5
  • Self improvement quotes
  • Self-Confidence Quote
  • SonarQube
  • Sony PlayStation 4
  • SQL
  • SQL Server
  • Success Quotes
  • Travel Quotes
  • Uncategorized
  • Uplifting Quotes
  • WCF (Windows Communication Foundation)
  • Web development
  • Wishes
  • Wishes for Newborn Baby

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org



Recent Posts

  • Azure Data Factory
  • What is Azure Active Directory?
  • Azure Virtual Machine
  • Azure Logic Apps
  • Azure Mobile Apps

Recent Comments

  • Yosianus on Error while sending json model in POST request to web API service using postman
  • How to take a screenshot in Google Nexus? Android phones
  • I wish you the best day of your life, as you only become 18 once! Birthday Wishes
  • With as much love, as I can share, I wanted to let you know I care. Sending lots of love your way, On your very special day! Happy Birthday, sweetheart! Birthday Wishes
  • Happy Birthday to the best mom ever! She is the true meaning of strength…she is an amazing person and I am the mother I am because of her. (Evan says I know more: p) I am beyond blessed to have her in my life! Love you mom! Birthday Wishes For Mom
  • Azure SQL Database Microsoft Azure
  • Microsoft AZ-900 Certification Exam Practice Questions – 7 Microsoft AZ-900 Certification Exam
  • Happy Diwali Wishes Greetings 2020 Happy Diwali Wishes
  • Microsoft Exam AZ-400 Certification Exam Practice Questions – 1 Uncategorized

Copyright © 2023 Desi banjara.

Powered by PressBook News WordPress theme