Last post Jan 25, 2018 10:05 AM by RageRiot
Jan 24, 2018 03:16 PM|RageRiot|LINK
I have a live webforms project and I noticed a strange issue today when the database went down.
When an exception occurs, the page is returned as follows:
I have created a test page to manually invoke an exception, and issue is still there.
I've added the following to my webconfig, but it doesn't work:
<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="/uk/error_deleteme" />
Does anyone know why this is happening?
Jan 24, 2018 04:03 PM|PatriceSc|LINK
The error is supposed to be shown using which language? This character is used when values are not matching a valid unicode characters but even other characters are looking weird.
If you are using a latin language I suspect it could be that you have an exception handler somewhere (when the db fails ?) that uses Response.Write to show binary data when an error happens ???
Jan 24, 2018 04:10 PM|RageRiot|LINK
Any errors should be shown in English.
If I view the source it's all garbled too.
Jan 24, 2018 04:22 PM|PatriceSc|LINK
And in the browser or by using F12 the page encoding is ?
For now it seems really something like rendering binary data as text making mosft of them being randomly invalid ???
Jan 24, 2018 04:34 PM|RageRiot|LINK
I can't see that information anywhere using F12.
The source is as follows:
I can see an error...
It may be unrelated, but this project uses a Master Page and a nested master page though everything works fine until there is an exception.
Jan 24, 2018 05:01 PM|PatriceSc|LINK
Sorry, more precisely I meant F12 Network, Response headers and looking at the "Content-Type" to see if you have something such as : text/html; charset=utf-8
Edit: I confirm that random bytes are producing a similar result. For some reason it seems binary content is rendered from the server side when an exception happens ???
Jan 24, 2018 05:09 PM|cnranasinghe|LINK
this thread, But not sure your environment is same as facts on the thread.
Jan 24, 2018 06:17 PM|RageRiot|LINK
I've just tried this on a different computer (same source version), and I get the correct error:
Looking at that thread, I think it might have something to do with compression.
I added this a long time ago to Global.asax.cs:
void Application_BeginRequest(object sender, EventArgs e)
// Implement HTTP compression
HttpApplication app = (HttpApplication)sender;
// Retrieve accepted encodings
string encodings = app.Request.Headers.Get("Accept-Encoding");
if (encodings != null)
// Check the browser accepts deflate or gzip (deflate takes preference)
encodings = encodings.ToLower();
app.Response.Filter = new DeflateStream(app.Response.Filter, CompressionMode.Compress);
else if (encodings.Contains("gzip"))
app.Response.Filter = new GZipStream(app.Response.Filter, CompressionMode.Compress);
Jan 25, 2018 09:44 AM|RageRiot|LINK
Ok, so I've had a chance to re-test.
If I comment out the Application_BeginRequest method it works.
Is there another/better way of compressing my (webforms) site?
Jan 25, 2018 09:55 AM|Eric Du|LINK
According to your description and error message, I found someone who meet the similar issue as you, please check the solutions:
Page displays random symbols instead of error message on Firefox:
ASP.NET GZip Encoding Caveats:
Jan 25, 2018 10:05 AM|RageRiot|LINK
protected void Application_Error(object sender, EventArgs e)
Response.Filter = null;
To the Global.asax.cs worked :)