做一个HttpModule ,用GetPreloadedEntityBody()取数据总是报引用空的异常.(同样代码在2003中可以).在BAIDU和GOOGLE上也搜到类似问题,但是没有看到答案...求教了!!
解决方案 »
- 有关asp.net文件依赖方式的缓存的问题,请高人指点
- ASP.NET后台程序发布问题
- Response.End()后代码还继续执行问题?
- 试图运行项目时出错:无法启动调试。没有正确安装调试器,请运行安装程序安装或修复调试器。各位大哥大姐叔叔阿姨,帮帮我吧,老师要检查的
- 使用ProfileBase创建ProfileCommon导致数据库连接失败的错误
- 那位高手帮忙看看我的程序
- 诚求:winform 的源代码---
- 如何在网页中加入支付宝功能
- 如何消除datagrid的表格,谢谢
- 在.ASPX中,javascript可否执行?
- asp.net中发邮件求助,紧急.
- 省市县 三级联动 ,数据如何存入数据库
自定义的HttpModules必须用HasEntitybody方法来检查web 服务器是否已经预加载了客户端的请求数据。
如果没有就必须使用ReadEntityBody来获取客户端的请求数据
HttpWorkerRequest wr = (HttpWorkerRequest) provider.GetService(typeof(HttpWorkerRequest));
string addr = wr.GetLocalAddress();
Response.Write(String.Format("NiC Address:{0}<BR>", addr));
byte[] bs = wr.GetPreloadedEntityBody();
String s = "";
if (bs != null && bs.Length >0)
s= System.Text.Encoding.Default.GetString(bs);
Response.Write(s + "<BR>");
if (!wr.IsEntireEntityBodyIsPreloaded())
{
Response.Write("normally shouldn't be here");
int n = 1024;
byte[] bs2 = new byte[n];
while (wr.ReadEntityBody(bs2,n) >0)
{
s = System.Text.Encoding.Default.GetString(bs2);
Response.Write(s + "<BR>");
}
} note, as IIS receives data on its TCP/IP connection from the browser, it sends a copy to the ASP.NET worker process through a named pipe. You use ReadEntityBody to read the data from this pipe. But you might not need to use ReadEntityBody if the data is not huge
如还不明白可与我联系:[email protected]
了NULL,依然没有解决问题!