Server.Transfer 执行子请求时出错 的一个原因
使用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 {
10 // hide the real error as it could be misleading
11 // in case of mismapped requests like /foo.asmx/bar
12 error = new HttpException(404, String.Empty);
13 }
14 }
15 else if (!(handler is Page)) {
16 // disallow anything but pages
17 error = new HttpException(404, String.Empty);
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 {
10 // hide the real error as it could be misleading
11 // in case of mismapped requests like /foo.asmx/bar
12 error = new HttpException(404, String.Empty);
13 }
14 }
15 else if (!(handler is Page)) {
16 // disallow anything but pages
17 error = new HttpException(404, String.Empty);
18 }
关键在于如果Handle不是继承自Page就会出错。
OK,打开代码,让Handle继承自Page,而不仅仅是IHttpHandler。
但是为什么要这样,修改后有没有问题,没有仔细考虑。
posted on 2008-10-08 20:32 sherwinzhu 阅读(4257) 评论(0) 编辑 收藏 举报