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 355497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:01:24+00:00 2026-05-12T12:01:24+00:00

The HttpModule works fine (hello is replaced with hello world) but for some reasons

  • 0

The HttpModule works fine (“hello” is replaced with “hello world”) but for some reasons images on the WebForms are not displayed when the module is added to the Web.config. When the module is removed from the Web.config, images on the WebForms are displayed.

Does anyone know why?

The HTML that is produced with or without the HttpModule is exactly the same!

//The HttpModule

public class MyModule : IHttpModule
{
        #region IHttpModule Members

        public void Dispose()
        {
            //Empty
        }

        public void Init(HttpApplication context)
        {
            context.BeginRequest += new EventHandler(OnBeginRequest);
            application = context;
        }

        #endregion

        void OnBeginRequest(object sender, EventArgs e)
        {
            application.Response.Filter = new MyStream(application.Response.Filter);
        }
}

//The filter – replace “hello” with “hello world”

public class MyStream : MemoryStream
{
        private Stream outputStream = null;

        public MyStream(Stream output)
        {
            outputStream = output;
        }

        public override void Write(byte[] buffer, int offset, int count)
        {

            string bufferContent = UTF8Encoding.UTF8.GetString(buffer);
            bufferContent = bufferContent.Replace("hello", "hello world");
            outputStream.Write(UTF8Encoding.UTF8.GetBytes(bufferContent), offset, UTF8Encoding.UTF8.GetByteCount(bufferContent));

            base.Write(buffer, offset, count);
        }
}
  • 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-05-12T12:01:24+00:00Added an answer on May 12, 2026 at 12:01 pm

    Are you applying the module to all requests? You shouldn’t, as it will mess up anything that’s binary. You could potentially just make your event handler only apply the filter when the content type is appropriate.

    It would be better only to apply the module to particular extensions to start with though.

    To be honest, your stream implementation is slightly dodgy too – it may well fail for characters which take up multiple bytes when encoded in UTF-8, and you’re decoding the whole buffer even when only part of it is written. Additionally, you might get “hello” split up as “he” and then “llo” which you don’t currently cope with.

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

Sidebar

Related Questions

I try to use ELMAH on my ASP.NET MVC2 application, it works fine on
I have NHibernate hooked up in my asp.net mvc app. Everything works fine, if
Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for
I am using elmah with an asp.net mvc 3 site and it works fine
I tried some work using http handler and found that we can not execute
There is a HttpModule that change Server field in Response Headers. But it does
i have a problem in asp.net web-application. I'm using UrlRewritingNet.UrlRewrite and it's works fine
I have dynamic CMS-driven (custom rolled, I know, wheels, etc. but not my decision!)
I've created an httpModule to handle URL remappings, and it works great on my
I have some proof concept code for a HTTP module. The code checks to

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.