您的位置:首页 > Web前端

Server.Transfer 执行子请求时出错 的一个原因

2008-10-08 20:32 218 查看
使用Server.Transfer进行页面的导向,总是莫名其妙的出错,今天接到电话,说一个系统总是登录不了.明明10.1前还是好好的,怎么放完假就换到了.

一遍一遍的调试,只有"执行子请求出错"着一个简单的说明.Google了N篇文章,尝试了很多的方法,还是不行.

就快要放弃的时候,想起来使用Reflactor查看微软的原代码,然后使用VS2008调试,终于找到的问题的原因.

在HttpServerUtility中

 1 if ((handler is StaticFileHandler || handler is DefaultHttpHandler) && 

 2    !DefaultHttpHandler.IsClassicAspRequest(filePath.VirtualPathString)) { 

 3     // cannot apply static files handler directly

 4     // -- it would dump the source of the current page 

 5     // instead just dump the file content into response

 6     try {

 7         response.WriteFile(physPath);

 8     } 

 9     catch {

         // hide the real error as it could be misleading 

         // in case of mismapped requests like /foo.asmx/bar 

         error = new HttpException(404, String.Empty);

     } 

 }

 else if (!(handler is Page)) {

     // disallow anything but pages

     error = new HttpException(404, String.Empty); 

 } 

关键在于如果Handle不是继承自Page就会出错。

OK,打开代码,让Handle继承自Page,而不仅仅是IHttpHandler。

但是为什么要这样,修改后有没有问题,没有仔细考虑。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐