环境:vs2012 ,iis 7.0
问题描述:
客户端submit一个file表单。服务端通过HttpWorkerRequest对象来获取读取文件前1000byte字节来解析出文件名称,文件类型等信息。返回给客户端。
不通过request.file读取剩余的file内容。
主要代码:
  public void ProcessRequest(HttpContext context)
    {        RequestFile file = new RequestFile(context);  //自己的file对象,通过HttpWorkerRequest类来获取文件类型等信息
        string size = string.Empty;
        if (file.ContentLength < 1024 * 1024)
        {
            size = file.ContentLength / 1024 + "KB";
        }
        else
        {
            size = file.ContentLength / 1024 / 1024 + "MB";
        }
        string json = string.Format("'{0}','{1}','{2}'", file.FileName, size, file.ContentType);
        context.Response.ContentType = "text/html; charset=utf-8";
        context.Response.Write("<script type='text/javascript'>window.top." + "ss" + "(" + json + ");</script>");
        context.Response.Flush();
        context.Response.End();
    }
程序断点执行完最后一句代码以后,如果是大容量文件,客户端依然会继续等待很久,才会收到响应,所以揣测,iis会继续读取文件内容,直至完成才开始返回response的响应信息。
有没有什么方法,api等,终止iis对客户端post的文件的读取,直接立刻返回响应http请求。
IISASP.NET 上传 大容量 http