More in this section
Forums / Developing with Sitefinity / Session NULL in MVC widget

Session NULL in MVC widget

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
1 posts, 0 answered
  1. kaarthick
    kaarthick avatar
    1 posts
    Registered:
    04 Jul 2016
    02 Aug 2016
    Link to this post

    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

1 posts, 0 answered