简体   繁体   中英

Sitecore.Context.Database is Web but GetItem() returns null for everything

Something is wrong with my Sitecore 8.2 environment but I'm not sure what. All of the GetItem() calls in my code are returning null. I've confirmed that Sitecore.Context.Database is not null and is the web database, and I switched to the web database and confirmed that all of the items are there and their IDs match the IDs I'm using in my GetItem() calls. I know that the connectionstring is correct, because the homepage of my site loads and is showing the logo and welcome text that are configurable fields in Sitecore. But every attempt to call Sitecore.Context.Database.GetItem() is returning null. Also tried:

SitecoreService service = new SitecoreService(Sitecore.Context.Database);
HomePage = service.GetItem<IRoot>(ItemReference.Hompage.Guid);

but that returns null as well.

You might want to look at the security settings on your items. If the items are there, in the correct language, but you are getting null, this usually means the context user does not have access.

You may have explicitly denied anonymous users, or not granted them read, or inheritance was broken at a higher level and previous 'read' access is no longer passing down to your items.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM