Hi I have the following block of code copied from a previous project and it throws a null exception. This is because the value of HttpContext.Current is set to null and it therefore cannot return HttpContext.Current.Application. Can someone help me work out why this value is null?
private static ISessionFactory SessionFactory
{
get
{
ISessionFactory sessionFactory = null;
sessionFactory = HttpContext.Current.Application["sessionFactory"] as ISessionFactory;
if (sessionFactory == null)
{
Configuration configuration = new Configuration().Configure();
sessionFactory = configuration.BuildSessionFactory();
HttpContext.Current.Application.Add("sessionFactory", sessionFactory);
}
return sessionFactory;
}
}