我想要在Global.asax的Application_Start方法中访问缓存。我正在尝试使用Context.Cache。当我从Visual Studio运行代码时,它工作得很好,但是当我在IIS服务器上运行它时,我得到:会话状态在此上下文中不可用。我想在应用程序启动时在缓存中播种一些值。我如何从Application_Start获取缓存?在Global.asax的Application_Start方法中访问缓存时出错
2
A
回答
8
哇。我找到了答案。使用变量HttpRuntime.Cache而不是Context.Cache。
1
是的,这改变了在IIS7切换到集成模式。 Application_Start执行得更早,所以HttpContext不可用。
Visual Studio使用Cassini,它在几个方面与完整的IIS不同。查看新发布的IIS Express,这些也可以用于Visual Studio。它是IIS 7.5的独立版本,因此您不会遇到在使用Cassini进行测试时不存在的生产问题。
相关问题
- 1. Global.asax的Application_Start方法没有被调用
- 2. 从global.asax发送Web请求(Application_Start()方法)
- 3. Global.asax上的WindowsMediaPlayer application_start
- 4. 注册RequestContext在Application_start(global.asax)
- 5. 在Global.asax中慢的Application_Start使得死锁
- 6. 不能在Global.asax中/打破的Application_Start
- 7. 访问到User.Identity中的Application_Start()
- 8. 为什么在使用RoleEntryPoint时无法访问Application_Start中的RoleEnvironment?
- 9. Application_End在重新启动时在Global.asax中的Application_Start后触发
- 10. 访问会话在Global.asax中的方法在MVC3环境
- 11. 制作缓存访问方法static
- 12. Global.asax Application_Start在调试时未触发,但在生产中触发
- 13. 帮助调试 - Application_Start何时在global.asax文件中运行?
- 14. 访问在MVC的Global.asax
- 15. 在Application_Start中访问ninject内核
- 16. 我可以在哪里从Global Application_Start访问ASP.NET应用程序缓存?
- 17. 一次在global.asax中访问的POST请求无法在CustomAuthorization类中访问 - WebAPI
- 18. 缓存访问
- 19. 访问Play的正确方法!在Scala模板缓存?
- 20. 正在缓存Facebook评论框的“URL无法访问”错误?
- 21. Global.asax Application_Start获取操作Url/RedirectToAction?
- 22. global.asax函数没有从Application_Start调用
- 23. Global.asax Application_start对每一个动作开火
- 24. 无法访问存储在缓存中的JSON文本文件
- 25. 从WCF访问appfabric缓存的错误
- 26. 访问ALAssetsLibrary时出现内存错误
- 27. 访问存储过程时出错
- 28. 的Global.asax和用户访问
- 29. Global.asax中的异步方法
- 30. 在访问特定URL时绕过Drupal缓存的简单方法