Automatically Resolving Home Item on an API Controller with Multiple Sites
Published at June 20, 2016 · 2 min read
I was writing a method in a Web Api controller that was supposed to get data from a field. For now, let’s call the field “MicroSite Name”. To do so, I wrote a method that could be simplified down to this: [HttpGet] public string GetMicroSiteName() { return _sitecoreService.GetHomeItem<ISite2HomeItem>().Settings.MicroSiteName; } When I called that method from the front-end, I received a Null Reference Exception. Confused by this, I dug into it a bit further....