Complete sources is here
Links :
Using 51Degrees.Mobi Foundation for accurate mobile browser detection on ASP.NET MVC 3 by Steve Sanderson
A Better ASP.NET MVC Mobile Device Capabilities ViewEngine by Scott Hanselan
public static class MobileHelpers { ... //Add firefox + firebug for help to debug public static void AddFireBug(this ViewEngineCollection ves) where T : IViewEngine, new() { ves.Add(new CustomMobileViewEngine(c => c.UserAgentContains("firefox"), "Mobile", new T())); } }Deuxièmement dans "Global.asax.cs" (Sources complètes ici) , je l'ai ajouté à ma fabrique de moteur
protected void Application_Start() { AjaxHelper.GlobalizationScriptPath = "http://ajax.microsoft.com/ajax/4.0/1/globalization/"; AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); // Add the auto mobile detection & redirection ViewEngines.Engines.Clear(); ViewEngines.Engines.AddIPhone<RazorViewEngine>(); ViewEngines.Engines.AddWindowsMobile<RazorViewEngine>(); ViewEngines.Engines.AddGenericMobile<RazorViewEngine>(); #if DEBUG // Just use it for debug JS in firebug & inspect HTML ViewEngines.Engines.AddFireBug<RazorViewEngine>(); #endif // Std engine ViewEngines.Engines.Add(new RazorViewEngine());}
protected void Application_Start() { AjaxHelper.GlobalizationScriptPath = "http://ajax.microsoft.com/ajax/4.0/1/globalization/"; AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); // Add the auto mobile detection & redirection ViewEngines.Engines.Clear(); ViewEngines.Engines.AddIPhone<RazorViewEngine>(); ViewEngines.Engines.AddWindowsMobile<RazorViewEngine>(); ViewEngines.Engines.AddGenericMobile<RazorViewEngine>(); #if DEBUG // Just use it for debug JS in firebug & inspect HTML ViewEngines.Engines.AddFireBug<RazorViewEngine>(); #endif // Std engine ViewEngines.Engines.Add(new RazorViewEngine());}
public static class MobileHelpers { ... //Add firefox + firebug for help to debug public static void AddFireBugYou could do the same thing with "F12" on IE if you are used it.(this ViewEngineCollection ves) where T : IViewEngine, new() { ves.Add(new CustomMobileViewEngine(c => c.UserAgentContains("firefox"), "Mobile", new T())); } }