2013-06-25 40 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);