我试图注入对 Session_End 事件的依赖,Global.asax.cs
但是当它被触发时,它会抛出 NullReferenceException,这是我的代码:
//This works
void Session_Start(object sender, EventArgs e)
{
var accessLogger = DependencyResolver.Current.GetService<IAccessLogger>();
}
//This does NOT work
void Session_End(object sender, EventArgs e)
{
var accessLogger = DependencyResolver.Current.GetService<IAccessLogger>();
}