求救:如何过滤FPRPC response
本人在开发sharepoint上过滤文件的下载response,做法是这样的:在HttpApplication的PreProcessHttpRequest事件里,将Response.Filter替换为自己实现的Stream对象,用来过滤Response里的文件内容。代码如下:
对于GET以及WebDAV的下载文件请求的处理是正常的,但是对于FPRPC的"get document"命令,在DefaultHttpHandler.BeginProcessRequest()函数里就会抛出一个HttpException异常:"The Http verb Post used to access Path '/_vti_bin/_vti_aut/author.dll' is not allowed".
请问这到底是什么原因?难道原先的Response.Filter不能被覆盖吗?
希望有专家可以解答,非常感谢!这个事情比较急啊.
public abstract class HttpFilterBase : Stream
{
private Stream _baseStream;
private bool _closed;
protected Stream BaseStream
{
get { return this._baseStream; }
}
public override bool CanRead
{
get { return false; }
}
public override bool CanWrite
{
get { return !_closed; }
}
public override bool CanSeek
{
get { return false; }
}
protected bool Closed
{
get { return _closed; }
}
public override long Length
{
get { throw new NotSupportedException(); }
}
public override long Position
{
get { throw new NotSupportedException(); }
set { throw new NotSupportedException(); }
}
protected HttpFilterBase(Stream _baseStream)
{
this._baseStream = _baseStream;
this._closed = false;
}
public override void Write(byte[] buffer, int offset, int count)
{
_baseStream.Write(buffer, offset, count);
}
public override void Close()
{
if (!_closed)
{
_closed = true;
_baseStream.Close();
}
}
public override void Flush()
{
_baseStream.Flush();
}
public override int Read(byte[] buffer, int offset, int count)
{
throw new NotSupportedException();
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotSupportedException();
}
public override void SetLength(long value)
{
throw new NotSupportedException();
}
}
// This filter changes all characters passed through it to uppercase.
public class HEResponseFilterStream : HttpFilterBase
{
private HttpApplication application;
public HEResponseFilterStream(Stream sink, Object source)
: base(sink)
{
application = (HttpApplication)source;
}
public override void Close()
{
base.Close();
}
public override void Flush()
{
HttpContext context = application.Context;
HttpRequest Request = context.Request;
HttpResponse Response = context.Response;
base.Flush();
}
// The Write method actually does the filtering.
public override void Write(byte[] buffer, int offset, int count)
{
HttpContext context = application.Context;
HttpRequest Request = context.Request;
HttpResponse Response = context.Response;
{
base.Write(buffer, offset, count);
return;
}
}
}
补充:.NET技术 , ASP.NET