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。
但是为什么要这样,修改后有没有问题,没有仔细考虑。
一遍一遍的调试,只有"执行子请求出错"着一个简单的说明.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。
但是为什么要这样,修改后有没有问题,没有仔细考虑。
相关文章推荐
- ASP.NET中在IHttpHandler里执行Server.Transfer时提示执行子请求时出错。(http://codeadmin.blog.163.com/blog/static/1158046532009512114926448/)
- Asp.Net Server.Execute、Server.Transfer报“执行子请求时出错”解决方案
- Server.Execute遇到执行子请求时出错
- server.Execute 执行子请求时出错
- 解决 ASP.NET Chart 控件出错 为 ChartImg.axd 执行子请求时出错
- servlet层调用biz业务层出现浏览器 500错误,解决方法 dao数据访问层 数据库Util工具类都可能出错 通过新建一个测试类复制代码逐步测试查找出最终出错原因
- 如果某个页面上点击按钮发起了一个http url请求,去执行一个action,但是还没等这个action完成,我就刷新了这个页面,然后又点击了这个按钮,这样之前的那次http url请求还在执行吗?
- 关于Tuxedo执行tmboot出错的几种原因
- button生成mschart图表,为 ChartImg.axd 执行子请求时出错
- 网站开发进阶(四)Tomcat Server处理一个http请求的过程
- 执行 webpack-dev-server –content-base src –hot –inline 出错
- 请求ajax失败或者不执行的原因
- 第一次使用MsChart运行提示:ChartImg.axd 执行子请求时出错。
- Server.Transfer跳转异常,post请求未找到HTTP处理程序
- iis中执行.aspx文件出错:由于无法创建应用程序域,因此未能执行请求。
- 解决 ASP.NET Chart 控件出错 为 ChartImg.axd 执行子请求时出错
- HTTP中404、405、500等请求错误出错原因
- 关于Server.Transfer(URL)和UrlReWrite的一个突发奇想
- Sql server Insert执行的秘密(上)一个最简单的INSERT分析