我正在尝试在Global.asax.cs
中注入对Session_End事件的依赖,但是当它被触发时会抛出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>();
}