I am currently working with mvc 4 and interested in implementing the DisplayModes feature which sniffs the browsers accessing the site and renders an appropriate view based upon the browser/device.
For example, code to check for iphone and render the applicable view:
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("iPhone")
{
ContextCondition = (context => context.Request.UserAgent.IndexOf
("iPhone", StringComparison.OrdinalIgnoreCase) >= 0)
});
I have read that out of the box it sniffs for mobile devices, and adds the mobile name to the view.
I want to create a similar, bit for tablets. Has anyone implemented this or instructions of how to do it? I can go check the user agent etc for tablet, but this feature is hit and miss so wondering if this has been achieved by anyone as of yet.