DNN 初探(第一小时)

1.下载了一个C#版本的DNN,编译源码,本来想监视一下install的过程,结果一下子就碰到了第一个麻烦。程序运行的时候会报错

错误内容为:Request is not available in this context

错误界面:

image 

原因如下:我用的是vista系统,使用的是IIS7

IIS7的设计方式已经改变,request context 已经不能再Application_Start事件中使用,解决问题的方法有两个:

1.将受影响的代码移出Application_Start

2.将代码移回IIS6,或其他等支持的IIS。

为了解决问题,我们可以将代码移到Application_Beginrequest中,用一个静态变量作为标志,只有初次进来的时候才会执行Application_Beginrequest中的部分代码。

参考:

http://mvolo.com/blogs/serverside/archive/2007/11/10/Integrated-mode-Request-is-not-available-in-this-context-in-Application_5F00_Start.aspx

http://www.vikramlakhotia.com/Accessing_HttpContextCurrent_in_Application_start_in_IIS_70_gives_server_error.aspx

posted @ 2009-08-07 17:53  ShelleyZhang  阅读(229)  评论(0编辑  收藏  举报