You develop an ASP.NET MVC application. The application has several Razor views.
The application must execute different server-sid
e code for desktop and mobile devices.
You need to choose an approach to support mobile devices.
Which two approaches can you use? Each correct answer presents a complete solution.
A. Use different controllers and view for both desktop and mobile browse
rs, but render the views using Bootstrap framework.
B. Create separate areas for desktop and mobile browsers, implementing independent controllers and views for each.
C. Use the same controllers for both desktop and mobile browsers, but render different v
iews depending on the device type.
D. Use different controllers and views for both desktop and mobile browsers, but render the views with the same Razor layout depending on the device type.
Explanation:
How ASP.NET MVC applications can present
mobile-specific pages
Since the Model-View-Controller pattern decouples application logic (in controllers) from presentation logic (in views), you can choose from any of the following approaches to handling mobile support in server-side code:
Create
separate areas for desktop and mobile browsers, implementing independent controllers and views for each. This option works best if youre displaying very different screens, containing different information and leading the user through different workflows o
ptimized for their device type. It may mean some repetition of code, but you can minimize that by factoring out common logic into an underlying layer or service.
Use the same controllers for both desktop and mobile browsers, but render different views depe
nding on the device type. This option works best if youre displaying roughly the same data and providing the same workflows for end users, but want to render very different HTML markup to suit the device being used.
Use the same controllers and views for
both desktop and mobile browsers, but render the views with different Razor layouts depending on the device type. This option works best if youre displaying identical data on all devices, but simply want to supply different CSS stylesheets or change a few
top-level HTML elements for mobiles.
References: https://docs.microsoft.com/en-us/aspnet/whitepapers/add-mobile-pages-to-your-aspnet-web-forms-mvc-application