void context_BeginRequest(object sender, EventArgs e) { var app = (sender as HttpApplication); string fullpath = app.Request.MapPath("~\\gc-response.txt"); app.Response.WriteFile(fullpath); filterContext = FilterContext.Create(); if (filters == null) { filters = new List <IPageProcessor>(); } if (forbiddenWordFilter == null) { forbiddenWordFilter = new ForbiddenWordFilter(); forbiddenWordFilter.AddForbiddenWord(new ForbiddenWordFilter.ForbiddenWord("shit", false)); forbiddenWordFilter.AddForbiddenWord(new ForbiddenWordFilter.ForbiddenWord("f**k", false)); forbiddenWordFilter.AddForbiddenWord(new ForbiddenWordFilter.ForbiddenWord("广告", false)); System.Diagnostics.Debug.Assert(filters != null, "filters == null !"); filters.Add(forbiddenWordFilter); } FilterStream filterStream = new FilterStream( app.Response.Filter, filters, filterContext); filterStream.Responsing += new EventHandler(filterStream_Responsing); app.Response.Filter = filterStream; }
public FilterStream(Stream stream, IList <IPageProcessor> processors) { _instance = stream; _processors = processors; if (_context == null) { _context = FilterContext.Create(); } }