有人可以給我一個例子或鏈接到在asp.net mvc中使用會話之一嗎?asp.net mvc session example
3
A
回答
10
與WebForms中的相同:
使用HttpContext.Current.Session對象。
HttpContext.Current.Session["UserName"] = "Jon";
string userName = HttpContext.Current.Session["UserName"];
+0
您提前10秒發佈! ^^ – 2009-07-29 11:37:12
0
隨着MVC Future庫是可以做到的要簡單得多
在Global.asax.cs
添加一行在Application_Start()
方法
ValueProviderFactories.Factories.Add(new SessionValueProviderFactory());
然後你就可以在控制器通過
$Session["YourName"] = "some value";
訪問會話或在查看
@Session["YourName"]
here is article到你的項目
相關問題
- 1. asp.net mvc example db
- 2. Google AppEngine Session Example
- 3. asp.net mvc session
- 4. ASP.Net MVC Nhibernate Session
- 5. ASP.NET MVC Session
- 6. ASP.NET MVC 3 Session
- 7. Asp.Net MVC和Session
- 8. ASP.NET MVC 5和Session
- 9. Asp.Net mvc Session Vs Cache
- 10. Session對象爲空後在ASP.NET MVC 4
- 11. ASP.NET Session
- 12. Session ASP.NET
- 13. ASP.Net inter session event
- 14. asp.net session dissappers
- 15. ASP.NET Session Recycles
- 16. mvc 3 session and authorizeAttribute
- 17. Session asp.net info not changing
- 18. ASP.NET Session TimeOut問題
- 19. ASP.NET 2.0 Session&Master Page
- 20. 它更昂貴或者Session變量或靜態模型ASp.net MVC
- 21. ASP.NET MVC從控制器傳遞信息,無需ViewData,ViewModel或Session
- 22. Asp.net-MVC中的Session和ViewData有什麼區別?
- 23. 在ASP.NET MVC 3中使用Unity存儲在Session中的對象
- 24. Request is still authenticated but Session [「account」] was lost in Asp.net MVC
- 25. Nhibernate Session關閉異常問題與Asp.net mvc telerik ajax網格
- 26. 轉換Session對象強類型對象在asp.net mvc的
- 27. ASP.net MVC 5 Session在調用Abandon之後未清除()
- 28. 在Cookies或Session中保存本地化(ASP.Net MVC 3)?
- 29. 在asp.net mvc中設置Session的持久性cookie過期?
- 30. Asp.Net中Session的問題
我想它的工作原理就像在web表單如何添加庫。 – 2009-07-29 11:36:07