I have a MVC4, .Net4.5 application where we are using sessions. For no apparent reason, MVC4 is not creating the Session ID Cookie. Below is authentication and sessionstate settings from web.config
我有一个MVC4,.Net4.5应用程序,我们正在使用会话。没有明显的原因,MVC4没有创建会话ID Cookie。以下是web.config中的身份验证和会话状态设置
<authentication mode="Forms">
<forms cookieless="UseCookies" loginUrl="~/Login" timeout="480"></forms>
</authentication>
<sessionState timeout="50" cookieless="UseCookies" mode="InProc"/>
It is not an issue with cookies as the Forms Auth cookie is present.
由于存在Forms Auth cookie,因此cookie不是问题。
Suggestions?
1 个解决方案
#1
5
For no apparent reason, MVC4 is not creating the Session ID Cookie.
没有明显的原因,MVC4没有创建会话ID Cookie。
Maybe you never stored anything in the session on the server:
也许您从未在服务器上的会话中存储任何内容:
Session["foo"] = "bar";
Only then you will see the session cookie being set to the response of this particular request. That's by design. Even if you enable ASP.NET Session on the server the cookie will never be set to the client until a value is stored in the session.
只有这样,您才会看到会话cookie被设置为此特定请求的响应。这是设计的。即使您在服务器上启用了ASP.NET Session,在将值存储在会话中之前,cookie也永远不会设置为客户端。
#1
5
For no apparent reason, MVC4 is not creating the Session ID Cookie.
没有明显的原因,MVC4没有创建会话ID Cookie。
Maybe you never stored anything in the session on the server:
也许您从未在服务器上的会话中存储任何内容:
Session["foo"] = "bar";
Only then you will see the session cookie being set to the response of this particular request. That's by design. Even if you enable ASP.NET Session on the server the cookie will never be set to the client until a value is stored in the session.
只有这样,您才会看到会话cookie被设置为此特定请求的响应。这是设计的。即使您在服务器上启用了ASP.NET Session,在将值存储在会话中之前,cookie也永远不会设置为客户端。