We just started using WURFL. We are currently tracking down an issue that causes our site to crash. The crash occurred after I added code to exclude Tablets from our mobile web app. When this code is commented out the problem goes away. So I have re-factored it a bit. Added a check to make sure the manager object is in the cache like it should be. We're going to put this new version up but I'd like to submit what I was doing in case I'm doing something horribly wrong.
In the Global.asax under Application_Start I placed the following:
Code: Select all
var configurer = new ApplicationConfigurer();
var manager = WURFLManagerBuilder.Build(configurer);
HttpContext.Current.Cache[WurflManagerCacheKey] = manager;
Code: Select all
var manager = System.Web.HttpContext.Current.Cache[MvcApplication.WurflManagerCacheKey] as IWURFLManager;
if ( manager == null )
{
var configurer = new ApplicationConfigurer();
manager = WURFLManagerBuilder.Build(configurer);
System.Web.HttpContext.Current.Cache[MvcApplication.WurflManagerCacheKey] = manager;
}
var device = manager.GetDeviceForRequest(request);
if ( device.GetCapability("is_tablet") == "true")
{
Session["isMobile"] = _isMobile = false;
}
Should I be checking the value coming back from WURFLManagerBuilder.Build? The code functions fine and properly excludes the tablet devices that we've tested. Its just the resource issue and the App Pool explosion that happened after we restarted the server but doesn't seem to happen all the time.