2013-06-25 109 views
0

我使用我的网站上WURFLManager(ASP.net C#4.0)来检测移动设备的能力。我遵循了演练hereWURFLManager总是返回null

在我Globl.asax的Application_Start()方法,我有这样的:

WURFLManagerBuilder.Build(new ApplicationConfigurer()); 

然后在我的ASPX页面我尝试使用WURFLManager像这样的:

if (Request != null && Request.UserAgent != null) 
{       
    IDevice device = WURFLManager.Instance.GetDeviceForRequest(Request.UserAgent); 
} 

的WURFLManager对象始终为空,因此引发对象引用错误。

回答

1

嗯,我找到了答案。看起来好像这个API在某个时候肯定有变化。我无法确定我们使用的DLL是否已更新。

但无论如何,这里是解决方案:

var mgr = WURFLManagerBuilder.Build(new ApplicationConfigurer()); 
var device = WURFLManagerBuilder.Instance.GetDeviceForRequest(Request.UserAgent);