By Javascript:
var language = window.navigator.userLanguage || window.navigator.language;
By check request header on server side:
Request.Headers["Accept-Language"]
Accept-Language:en-US;q=0.8,en;q=0.6
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);
}
Subscribe to:
Posts (Atom)