Session NULL in MVC widget
I have a controller called Authenticate Controller.
I have created a MVC widget using authnticate controller. The code has a session value stored in an object. I ran this locally it works fine. When i add as a widget and insert into a page / template it throws following error:
NullReferenceException: Object reference not set to an instance of an object.
CODE:
[ControllerToolboxItem(Name="Authenticate",Title="Authenticate",SectionName="MVCWidget")]
public class AuthenticateController : Controller
private Authentication oSessionAuthRequest;
public Authentication SessionAuthRequest
get
if (oSessionAuthRequest == null)
oSessionAuthRequest =(Authentication)Session[Constants.SessionKey]; //Session is null.
//NullReferenceException: Object reference not set to an instance of an object.
return oSessionAuthRequest;
set
Session[Constants.SessionKey] = value;
STACK TRACE FOR ERROR
[NullReferenceException: Object reference not set to an instance of an object.]
System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value) +718
Telerik.Sitefinity.Mvc.ControllerActionInvoker.DeserializeControllerProperties(MvcProxyBase proxyControl) +2079
Telerik.Sitefinity.Mvc.ControllerActionInvoker.TryInvokeAction(MvcProxyBase proxyControl, String& output) +265
Telerik.Sitefinity.Mvc.Proxy.MvcControllerProxy.ExecuteController() +89
System.Web.UI.Control.PreRenderRecursiveInternal() +155
System.Web.UI.Control.PreRenderRecursiveInternal() +240
System.Web.UI.Control.PreRenderRecursiveInternal() +240
System.Web.UI.Control.PreRenderRecursiveInternal() +240
System.Web.UI.Control.PreRenderRecursiveInternal() +240
System.Web.UI.Control.PreRenderRecursiveInternal() +240
System.Web.UI.Control.PreRenderRecursiveInternal() +240
System.Web.UI.Control.PreRenderRecursiveInternal() +240
System.Web.UI.Control.PreRenderRecursiveInternal() +240
System.Web.UI.Control.PreRenderRecursiveInternal() +240
System.Web.UI.Control.PreRenderRecursiveInternal() +240
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4090