NopContext.Current.User is always null

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 13 años
I've been developing an application based on nopCommerce 1.60. I'm developing on Windows 7 Pro 64bit.

I'm deploying the application to Windows server 2003 R2 (32bit) for staging and this works fine. It works perfectly and exactly like when I run it on the Visual Studio dev server.

I've just deployed the code to the live server for testing in that environment and I've got a real show stopper. NopContext.Current.User is always null!

The live server is Windows 2003 R2 64bit, and this is the only difference I can see. I've been through every page of the site settings in IIS on both servers and made sure every setting is the same, I've also done the same for the Application Pool.

I don't know what else I could try.

Any suggestions?
Hace 13 años
I have the same problem ....
Hace 13 años
Solved ...
Hace 13 años
Care to elaborate?
Hace 13 años
My mistake was not to add the Application_BeginRequest method in global.asax file. this initialize zetacontext. when I add following snippet in the file, then the problem solved..
  

void Application_BeginRequest(object sender, EventArgs e)
        {
            ZetaConfig.Init();
            if (!InstallerHelper.ConnectionStringIsSet())
            {
                InstallerHelper.RedirectToInstallationPage();
            }
        }



here ZetaConfig is my class in my application
Hace 13 años
Presuming you mean NopConfig.Init(); I can't see how this can affect the NopContext .

        /// <summary>
        /// Initializes the NopConfig object
        /// </summary>
        public static void Init()
        {
            if (!_initialized)
            {
                ConfigurationManager.GetSection("NopConfig");
                _initialized = true;
            }
        }
            


Can you elaborate further.

Thanks
Hace 13 años
I think it overwrites HttpContext to ZetaContext ... What do u think?

public static NopContext Current
        {
            get
            {
                if (HttpContext.Current == null)
                {
                    object data = Thread.GetData(Thread.GetNamedDataSlot("NopContext"));
                    if (data != null)
                    {
                        return (NopContext)data;
                    }
                    NopContext context = new NopContext();
                    Thread.SetData(Thread.GetNamedDataSlot("NopContext"), context);
                    return context;
                }
                if (HttpContext.Current.Items["NopContext"] == null)
                {
                    NopContext context = new NopContext();
                    HttpContext.Current.Items.Add("NopContext", context);
                    return context;
                }
                return (NopContext)HttpContext.Current.Items["NopContext"];
            }
        }

Hace 13 años
I'm sorry, I still don't see where you're getting ZetaContext from
Hace 13 años
my last post is about nopcontext ....
Hace 12 años
I'm experiencing this problem with a fresh install on a new server. It worked just fine on one of our "older" servers (1 year old), but this one I've tracked it down to the NopContext.Current.User being Null always. I've looked through the forums and couldn't find a solid answer.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.