Quantcast
Channel: displaymode for mobile with desktop view for ipad in asp.net mvc 4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3

displaymode for mobile with desktop view for ipad in asp.net mvc 4

$
0
0

Hi I have a MVC 3 application, recently converted to mvc 4 and added mobile views. I want to add displaymodes for Mobile with desktop view for tablets specially for iPad(traffic mainly from here).

I have it like this in my code

DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode()            {                ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf("iPad", StringComparison.OrdinalIgnoreCase) >= 0)            });              DisplayModeProvider.Instance.Modes.Insert(1, new DefaultDisplayMode("Mobile")            {                ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf("Mobile", StringComparison.OrdinalIgnoreCase) >= 0)            });   

and Set the output cache varybycustom like below

public override string GetVaryByCustomString(HttpContext context, string custom)  {            string strUserAgent = context.Request.UserAgent.ToLower();            if (strUserAgent.Contains("ipad"))            {                return base.GetVaryByCustomString(context, custom);            }            if (Request.Browser.IsMobileDevice)            {                    return "mobile";                           }            return base.GetVaryByCustomString(context, custom);}   

I am using same urls for both mobile and desktop.

ISSUE:The Issue is after deploying the app to azure. after 1 hour the mobile gets desktop view for few urls. there is inconsistency.

can anyone help me where i am wrong. I even turned off outputcache still same issue.


Viewing all articles
Browse latest Browse all 3

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>