Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8842563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:59:23+00:00 2026-06-14T10:59:23+00:00

I have a very basic ASP.NET response filter that works fine. I use it

  • 0

I have a very basic ASP.NET response filter that works “fine.” I use it to replace the domain for static resources.

My code in the controller looks like this:

    protected override void OnActionExecuted(ActionExecutedContext filterContext)
    {
            _cdnRewriter.Stream = filterContext.RequestContext.HttpContext.Response.Filter;
            filterContext.RequestContext.HttpContext.Response.Filter = _cdnRewriter;
    }

And the rewrite filter itself:

    public override void Write(byte[] buffer, int offset, int count)
    {
        var html = Encoding.Default.GetString(buffer, offset, count);

        //manipulate html

        byte[] outData = Encoding.Default.GetBytes(html);
        Stream.Write(outData, 0, outData.GetLength(0));
    }

For certain pages on my site (I can’t find the rhyme or reason yet), I get a “HTTP Web Exception: Invalid use of response filter” perhaps 90% of the time. Simply refreshing a dozen times will get the correct output, but refreshing again will show the exception:

[HttpException (0x80004005): Invalid use of response filter]
   System.Web.HttpResponseStreamFilterSink.VerifyState() +4097234
   System.Web.HttpResponseStreamFilterSink.Write(Byte[] buffer, Int32 offset, Int32 count) +28
   NeoSmart.Web.CdnRewriteFilter.Write(Byte[] buffer, Int32 offset, Int32 count) +452
   System.Web.HttpWriter.FilterIntegrated(Boolean finalFiltering, IIS7WorkerRequest wr) +359
   System.Web.HttpResponse.FilterOutput() +121
   System.Web.CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +119
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165

Am I doing something wrong in my response filter?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:59:24+00:00Added an answer on June 14, 2026 at 10:59 am

    I probably should have known better: response filters should not be shared. I was using an object per class, creating a new response filter each time the OnActionExecuted function was called resolved the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Probably a very basic beginner question. Imagine the following situation: I have an ASP.NET
I have some very basic semaphore code that works great on Linux, but cannot
I have an ASP.NET app, very basic, but right now too much code to
I have a very basic ASP.NET web site. It has a single page (TestPage.aspx)
I'm a little new to asp.net mvc and I have a question (very basic).
I have a very simple app on my local machine that uses the ASP.NET
I've got a very basic ASP.Net MVC project where I'd like to use a
ASP.NET 2.0, SQL 2005. I have a very basic insert statement. I enter all
I have a very basic email submission form in my ASP.NET MVC 3 app.
I have veeeeryyy basic singleton in asp.net web application: [ThreadStatic] private static BackgroundProcessManager2 _Instance;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.