NopContext.Current.User is always null

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
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?
13 years ago
I have the same problem ....
13 years ago
Solved ...
13 years ago
Care to elaborate?
13 years ago
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
13 years ago
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
13 years ago
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"];
            }
        }

13 years ago
I'm sorry, I still don't see where you're getting ZetaContext from
13 years ago
my last post is about nopcontext ....
12 years ago
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.