Sitecore NullReferenceException on GetBrowserClassString

爱⌒轻易说出口 提交于 2019-12-11 04:57:12

问题


It was a beautiful day, and I came into work and Sitecore randomly gives me this:

[NullReferenceException: Object reference not set to an instance of an object.]
   Sitecore.UIUtil.GetBrowserClassString() +491
   Sitecore.sitecore.login.LoginPage.AddBrowserAttributes() +134
   Sitecore.sitecore.login.LoginPage.OnPreRender(EventArgs e) +434
   System.Web.UI.Control.PreRenderRecursiveInternal() +112
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4296

Not only was this an interruption to said day, it was altogether out of nowhere. It does not appear that I or any on my team have made any affecting changes, and it's been working fine.

Any ideas?


回答1:


We had this issue for a MultiSite Sitecore instance using Sitecore 6.5. The issue was that, as @WeekendWarrior alluded to, the Capabitilities Type was null. I found the solution on the Sitecore forum; however, I thought it'd be useful duplicate the simple, quick-fix part of the posted answer here because you need a Sitecore account to access the forum:

In your default site Content Editor, locate /sitecore/layout/Devices/Default and in the field Capabilities Type - Type, Assembly enter:

Sitecore.Web.Configuration.InternetExplorerCapabilities, Sitecore.Kernel

Save, then publish that item.




回答2:


Digging into GetBrowserClassString() with reflector (Sitecore.Kernel.dll), the only possible LOC that could trigger the null reference errors is:

Client.Device.Capabilities.Browser.MajorVersion // in the Sitecore namespace

Did you change your user agent string with a plugin? this might trip up this line of code. Regardless, I recommend that you put this line of code in your solution (or another test sitecore solution, debug it and see what part of it is null.



来源:https://stackoverflow.com/questions/23300839/sitecore-nullreferenceexception-on-getbrowserclassstring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!