If we examine our layout page, _Layout.cshtml
, we see that a bulk of our app's presentation layout is contained within this file. It then seems logical that if we create a layout page specific to mobile devices, we would certainly be on the fast path to offloading some of the presentation logic from the client to the server.
As we have already seen, convention over configuration is pervasive in the ASP.NET MVC 4 framework. One of the slickest extension points in my opinion is the ability to use a .Mobile
extension within the name of a view, partial view, or layout to target mobile devices. We will begin extending our support to the mobile web with a mobile layout.
Begin by creating a copy of the _Layout.cshtml
file in ~/Views/Shared,
and rename the copy to _Layout.Mobile.cshtml
. The contents of the Shared
folder is shown in the following screenshot:
Open up the new _Layout.Mobile.cshtml
file and locate the line used to display the app title.
<p class="site-title...