推荐:asp.net2.0 URL重写以及urlMappings问题(1)在asp.net2.0中的urlMappings倒是非常好用,可惜暂不支持正则表达式,不过,好在如果用IHttpModule的话不管什么样的请求都会先经过IHttpModule这样就为URL重写提供了一个好机会:
由于一旦进行了URL重写,原先的WEBFORM中的Action会发生改变,容易造成:请求的资源不存在问题具体怎么样?各位DX看看就清楚了!!!
所有才有了这个ResponseFilter了,实现如下:
public class ResponseFilter : System.IO.Stream
{
public ResponseFilter(System.IO.Stream sink, string _str)
{
_sink = sink;
//
// TODO: 在此处添加构造函数逻辑
//
this.str = _str;
}
private string str = "";
private System.IO.Stream _sink;
private long _position;
private System.Text.Encoding end = System.Text.Encoding.GetEncoding("GB18030");
private System.Text.StringBuilder oOutput = new System.Text.StringBuilder();
// The following members of Stream must be overriden.
public override bool CanRead
{
get { return true; }
}
public override bool CanSeek
{
get { return true; }
}
public override bool CanWrite
{
get { return true; }
}
public override long Length
{
get { return 0; }
}
public override long Position
{
get { return _position; }
set { _position = value; }
}
public override long Seek(long offset, System.IO.SeekOrigin direction)
{
return _sink.Seek(offset, direction);
}
public override void SetLength(long length)
{
_sink.SetLength(length);
}
新闻热点
疑难解答
图片精选