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