I occasionally see the below error in my logs
Error processing robots.txt
Exception: Glass.Mapper.MapperExceptioMessage: Service has been disposed, cannot create object
My code in Robotservice is as below
#region Injected
//DI Implementation
private readonly IMvcContext _mvcContext;
public RobotsService(IMvcContext mvcContext)
{
_mvcContext = mvcContext;
}
#endregion
public string GetRobotsForItem()
{
var homeItem = _mvcContext.GetHomeItem<ISitecoreItem>();
...
...
return <some text>;
}
While debugging, I see that the data source is null
for _mvcContext
and hence Glass is complaining about this. When I searched(blogs, pages, etc) for this error, I see that DI should be implemented and is the solution for this error. But I already have DI Implemented and working in almost all scenarios. Any thoughts or ideas on this?
Thanks in Advance!