I am dealing with some code that uses a custom HttpResponse filter in an asp.net application.

response.Filter = new HtmlResponseFilterStream();

This HtmlResponseFilterStream inherits from MemoryStream. The write method has been overriden to get the contents of the HTTP response. I use Encoding.UTF8.GetString to get the contents of the page in chunks.

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


In my local machine if I go to any page and debug the code I can see the the variable contentInBuffer populated with the actual html contents. Both with local ISS or iss express. This also works in our production environment.

However, if I go to a test machine things don't work as expected. If I debug the contents inside the write method (using remote debugger). I get some weird characters instead. So I guess this is due to some different encoding used.. maybe..

Both production and test servers have same specs with same OS and iis server versions.

I checked .Net Globalization settings and the encodings are set to UTF-8 for Request, Response Headers and Response in both machines.

I am pretty sure this has to be something related to the environment settings. Not sure if it's related with IIS or windows.

Any idea anyone?

Related posts

Recent Viewed