在asp.net中的域之间共享会话数据,困惑!
好的,这是我的问题,我想维护两个应用程序或域之间的会话数据(例如:www.abc.com 和 secure.abc.com)。
我在网上读到过这方面的内容,但很多人指出了许多不同的方法来做到这一点,人们对所有人都评论了 +ve 和 -ve 回应。另外,许多人只是提供理论答案,做这做那,但根本没有代码。
这些步骤就是所需要的全部吗? 1) 在 web.config 中:
2) 将会话数据存储在 sql DB 中:(在准备用于存储会话的数据库之后)
<sessionState mode="SQLServer" sqlConnectionString="Data Source=YourServer;
Integrated Security=True;database=MySessionDB" sqlCommandTimeout="30"
allowCustomSqlDatabase="true"/>
<machineKey decryption="AES" validation="SHA1" decryptionKey="..." validationKey="..." />
3)Am对这个感到困惑:我想像这样设置会话 cookie 的域 Response.Cookies["ASP.NET_SessionId"].Domain = ".abc.com"; 但是这段代码应该写在哪里呢? 此条目: http://mgrzyb.blogspot.com/2007/12 /aspnet-and-subdomains.html 说:使用 System.Web.SessionState.SessionIDManager 作为基类,但 SaveSessionID 方法不是虚拟的,因此无法重写。选项是:显式重新实现接口方法或装饰 SessionIDManager 类,并在调用 SessionIDManager.SaveSessionID 之后将 Response.Cookies[SessionIdCookieName].Domain 设置为我们的域。
只有作者提供了真实的代码,第3步才会清楚。
任何人都可以提供它的代码。
加上所有这 3 个步骤足以在域之间共享会话吗?
Ok, here's my problem, i want to maintain session data between two applications or domains (eg:- www.abc.com and secure.abc.com).
I have read on net about this, but many people pointing many different ways to do it, with people commenting +ve and -ve responses to all. Plus many are just providing theoretical answer, do this and that ,but no code at all.
are these steps all that is required?
1) in web.config: <httpCookies domain=".abc.com"/>
2) store session data in sql DB as:(after preparing the db for storing sessions)
<sessionState mode="SQLServer" sqlConnectionString="Data Source=YourServer;
Integrated Security=True;database=MySessionDB" sqlCommandTimeout="30"
allowCustomSqlDatabase="true"/>
<machineKey decryption="AES" validation="SHA1" decryptionKey="..." validationKey="..." />
3)Am confused about this one: i want to set the domain for the session cookie like this
Response.Cookies["ASP.NET_SessionId"].Domain = ".abc.com";
But where should this code be written?
this entry: http://mgrzyb.blogspot.com/2007/12/aspnet-and-subdomains.html says: use System.Web.SessionState.SessionIDManager as a base class but the SaveSessionID method is not virtual so cannot be overridden. Options are: either explicitly re-implement the interface method or decorate SessionIDManager class and after calling SessionIDManager.SaveSessionID set Response.Cookies[SessionIdCookieName].Domain to our domain.
Only if the author had provided real code, step 3 would have been clear.
Can anyone provide the code for it.
Plus all this 3 steps enough to share session among the domains?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第三步语句可以根据以下内容编写在global.asax中: http://www.know24.net/blog/ASPNET+Session+State+Cookies+And+Subdomains.aspx
the 3rd step statement can be written in global.asax according to: http://www.know24.net/blog/ASPNET+Session+State+Cookies+And+Subdomains.aspx