문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top