HttpContext.Current.Session["Id"]
和仅使用列表保存参数有什么区别?使用HttpContext.Current.Session [“Id”]
3
A
回答
0
会话是可用的跨页和交叉请求另一方面列表只是为了一个请求。他们都可以存储对象,但他们有不同的对象生命周期。
编辑:基于OP的评论
- 是InProc模式,存储在Web服务器上存储会话状态。 这是默认设置。
- StateServer模式,它在单独的进程 中存储会话状态,称为ASP.NET状态服务。这可确保在重新启动Web应用程序时保留会话状态 ,并使会话 状态对Web场中的多个Web服务器可用。
- SQLServer模式将会话状态存储在SQL Server数据库中。此 可确保在重新启动Web应用程序 时保留会话状态,并使Web会话中的多个Web 服务器可以使用会话状态。
- 自定义模式,可让您指定自定义存储提供程序。
- 关闭模式,禁用会话状态。 MSDN
0
ASP.NET是无状态的。因此,如果您将某些东西存储在列表中,那么在该请求完成后,如果您希望它可用,则该列表将需要保存在某处。
将每个请求看作是程序的新调用。如果您希望数据在调用中保持不变,那么您必须将其存储在某个地方。
+0
我该如何储存它的任何想法! – 7addan 2013-03-18 11:13:16
相关问题
- 1. HttpContext.Current.Session总是空
- 2. HttpContext.Current.Session是mvc
- 3. HttpContext.current.Session返回Nothing
- 4. HttpContext.Current.Session vs Context.Session
- 5. HttpContext.Current.Session为空
- 6. OWIN和HttpContext.Current.Session
- 7. HttpContext.Current.Session为空
- 8. HttpContext.Current.Session在实用类(ASP.NET MVC)中使用时返回null
- 9. 调用异步webservices时HttpContext.Current.Session为空
- 10. 页面间销毁HttpContext.Current.Session
- 11. HttpContext.Current.Session给出一个StackOverflowException?
- 12. HttpContext.Current.Session在OnPostAuthenticateRequest中为null
- 13. 负载平衡的HttpContext.Current.Session
- 14. HttpContext.Current.Session混淆在Asp.net MVC 3.0
- 15. WCF + Silverlight的+ HttpContext.Current.Session是空
- 16. 如何在抽象类的静态属性中使用HttpContext.Current.Session。
- 17. HttpContext.Current.Session [“accesstoken”]。当设置值时,ToString()为null
- 18. HttpContext.Current.Session为空请求图像。为什么?
- 19. 如何访问类库中的HttpContext.Current.Session?
- 20. ASP.Net状态服务器和访问HttpContext.Current.Session
- 21. 为什么Global.asax中的HttpContext.Current.Session为null?
- 22. ASP.NET HttpContext.Current.Session突然总是为空
- 23. HttpContext.Current.Session在Ashx文件中为空
- 24. 无法检索HttpContext.Current.Session状态的值
- 25. Session和HttpContext.Current.Session之间的区别
- 26. HttpContext.Current.Session在路由请求时为空
- 27. 当AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); HttpContext.Current.Session被破坏时。
- 28. HttpContext.current.Session在错误中被清除页面
- 29. ASP.NET + C#HttpContext.Current.Session为空(里面的WebService)
- 30. 为什么HTTPContext.Current.Session在ASP .Net MVC应用程序中使用SignalR 2.x库?
是的,这就是我正在寻找的生活时间我认为会议是不会持续的这是正确的吗? – 7addan 2013-03-18 11:11:43
检查我更新的答案。 – Adil 2013-03-18 11:19:40
thx我会试试:) – 7addan 2013-03-18 11:24:29