Session has not been configured for this application or request error : <p>I am very new to asp.net I recently I came across this exception:</p>

<blockquote>
  <p>System.InvalidOperationException</p>
</blockquote>

<p>The details of the exception says:</p>

<blockquote>
  <p>Session has not been configured for this application or request.</p>
</blockquote>

<p>Here is the code snippet where it happens:</p>

<pre><code>[HttpPost]
        public object Post([FromBody]loginCredentials value)
        {
            if (value.username.Equals("Admin")
                &amp;&amp;
                value.password.Equals("admin"))
            {
                HttpContext.Session.Set("userLogin", System.Text.UTF8Encoding.UTF8.GetBytes(value.username)); //This the line that throws the exception.
                return new
                {
                    account = new
                    {
                        email = value.username
                    }
                };
            }
            throw new UnauthorizedAccessException("invalid credentials");
        }
</code></pre>

<p>I have no idea why it's happening or what does this error actually mean. 
Can someone please explain what might be causing this?</p>
