.Net Mvc Interview Question

2 What is Bundling and Minification in MVC?

Answer

Bundling and minification are two new techniques introduced to improve request load time. It improves load time by reducing the number of requests to the server and reducing the size of requested assets (such as CSS and JavaScript).

Bundling

It lets us combine multiple JavaScript (.js) files or multiple cascading style sheet (.css) files so that they can be downloaded as a unit, rather than making individual HTTP requests.

Minification

It squeezes out whitespace and performs other types of compression to make the downloaded files as small as possible. At runtime, the process identifies the user agent, for example IE, Mozilla, etc. and then removes whatever is specific to Mozilla when the request comes from IE.

Learn more here – Bundling and Minification in Visual Studio 2012 or Migrate Existing Website

3 How can we pass the data From Controller To View In MVC?

Answer

There are three options in Model View Controller (MVC) for passing data from controller to view. This article attempts to explain the differences among ViewData, ViewBag and TempData with examples. ViewData and ViewBag are similar and TempData performs additional responsibility. The following are the key points on those three objects.

ViewData

  • The ViewData is used to move data from controller to view.
  • The ViewData is a dictionary of objects that are derived from the “ViewDataDictionary” class and it will be accessible using strings as keys.
  • ViewData contains a null value when redirection occurs.
  • ViewData requires typecasting for complex data types.
  • ViewBag

  • ViewBag is just a dynamic wrapper around ViewData and exists only in ASP.NET MVC 3. ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0.
  • ViewBag doesnt require typecasting for complex data types.
  • ViewBag also contain a null value when redirection occurs.
  • TempData

  • ViewData moves data from controller to view.
  • Use TempData when you need data to be available for the next request, only. In the next request, it will be there but will be gone after that.
  • TempData is used to pass data from the current request to the subsequent request, in other words in case of redirection. That means the value of TempData will not be null.
  • Learn more here – Various Ways to Pass Data From Controller to View in MVC 4

    1 What is Partial View in MVC?

    A partial view is a chunk of HTML that can be safely inserted into an existing DOM. Most commonly, partial views are used to componentize Razor views and make them easier to build and update. It can also be returned directly from controller methods. In this case, the browser still receives text/HTML content but not necessarily HTML content that makes up an entire page. As a result, if a URL that returns a partial view is directly invoked from the address bar of a browser, an incomplete page may be displayed. This may be something like a page that misses title, script and style sheets.

    What is Spring MVC?

    It is a Java framework which is used to build web applications. It follows the Model-View-Controller design pattern. Not just that, it also implements all the basic features of a core Spring Framework like Inversion of Control, Dependency Injection. Spring MVC provides a dignified solution to use MVC in Spring Framework by the help of DispatcherServlet. In this case, DispatcherServlet is a class that receives the incoming request and maps it to the right resource such as Controllers, Models, and Views.

    Top MVC Interview Questions And Answers | ASP.NET MVC Interview Questions And Answers | Simplilearn

    Related Posts

    Leave a Reply

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