Question 89


2.4.3 Question

Multiple Choice

You are creating a different view for each of several different browsers/devices, such as Home.iemobile.cshtml and Home.IPad.cshtml. What is the best way to implement it so your application knows to look for the specific views?

  • A. Use the viewport <meta> tag.
  • B. Add a new DisplayModeProvider for each of the special view types you want to support.
  • C. Put logic into each action to select the appropriate view based on information in the request.
  • D. You don’t have to do anything. The framework automatically handles browser/device detection by reading the new extensions on the views.

Answer:

B
Explanation
A. Incorrect: The viewport <meta> tag does not do any direction to views; it is strictly a client-side helper.
B. Correct: Adding a DisplayModeProvider for each type of special view, such as IEMobile or IPad, informs the framework to use those views where the context condition is fulfilled.
C. Incorrect: Putting logic into each action could be done, but it would be time-consuming and difficult to maintain. The DisplayModeProvider does the work for you in the background and eliminates the need for special code.
D. Incorrect: The framework does not make any assumptions by itself; it only knows what to do based on configurations that it has been given.