Question

I have an application that needs to support both desktop and tablet browsing. Both versions will be significantly different, using different Layouts in /Views/Shared/

In the Controller I am currently reading the user agent string and returning different Partial Views, which are parsed within the one Layout. I want to have two different Layouts, one which gets rendered for tablets and one for desktop. Currently I have:

/Views/Shared/_HomeLayout.cshtml
/Views/Shared/_HomeLayoutTablet.cshtml

How do I read the user agent string and have the server render the correct View before my own Controllers get called?

Was it helpful?

Solution

You can still use mobile views and the contextcondition to return a different view, even for partials.

http://www.asp.net/mvc/tutorials/mvc-4/aspnet-mvc-4-mobile-features

From the examples in this post, if you wanted a view to be considered only for a mobile, you create 2 versions, one with the .mobile.cshtml extension.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top