MVC 4 mobile and tablet view separation

Viewed 4484

I'm trying to make separate views for Tablet and Mobile. In app_start i have this code

DisplayModeProvider.Instance.Modes.Insert(0, new
        DefaultDisplayMode("Tablet")
        {
            ContextCondition = (ctx =>
            ctx.Request.UserAgent.IndexOf("iPad", StringComparison.OrdinalIgnoreCase) >= 0 ||
            ctx.Request.UserAgent.IndexOf("Android", StringComparison.OrdinalIgnoreCase) >= 0)
        });

I've created two layout files, one for mobile and one for Tablet. But there is conflict when i'm accessing from mobile device which is on Android. It redirects me to layout.tablet. How could i separate those two devices?

4 Answers
Related