0

I am trying to add sessionstate to my existing asp.net application. I have added

httpContext.Current.SetSessionStateBehavior(SessionStateBehavior.Required)

to the global.asax file but each time i make a call to the api, a new session is created.

here is how i am trying to view the session

        var session = HttpContext.Current.Session;

        if (session != null)
        {
            if (session["TestSession"] == null)
            {
                session["TestSession"] = "Session Exists"
            }
            return "TestSession: " + session["TestSession"];
        }

        return ("No Session");

Just wondering if anyone else has encountered this problem, i am using a session state sqldatabase to store the session

0 Answers0