Tuesday, September 4, 2012

ASP.NET MVC 4, Browser-Specific Views



private void registerDisplayMode(string agent, int index = 0)
{
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode(agent)
{
ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf
(agent, StringComparison.OrdinalIgnoreCase) >= 0)
});
}

protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();

FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);

registerDisplayMode("iPhone", 0);
registerDisplayMode("iPad", 1);
}


No comments:

Post a Comment