I am trying to debug a weird issue I am experiencing with a MVC2 solution I inherited from previous developers.
The issue is that if, for instance, I remove a necessary semi-colon from Site.Master, I do not see the appropriate "Server Error" page when I attempt to run the site. Instead, I am seeing a full screen of garbage characters. IE prompts to open/save the file instead of rendering garbage text by default -- but if you open, you see the same junk.
I've poked around a bit using Firebug, but I haven't seen anything super useful. I can only assume that a piece of code is expecting valid mark-up, receiving invalid mark-up, and issuing a response that is encoded differently due to this invalid mark-up.
This does not happen on a sample project, though, only on this development app. I have no idea what is going on when invalid mark-up is ran. Any advice on how to trace this issue further?
Example
EDIT:
- Custom Error Handling is not enabled.
- There is an "Error.aspx" page in under /Views/Shared, excluding it does not seem to do anything to the project.
- There are no OnException controller extensions.
- I've tried commenting all the content out of the Master Page and then throwing a server error -- still generates garbage.
- Looked at the Global.asax and did not see anything out of the ordinary.
- Skimmed the web config. It's rather large. I looked for things regarding errors, didn't see anything other than noting that custom error handling was not enabled.
EDIT2: Here is the code causing issues. I am not sure why yet, but I thought I'd post it for science.
pub开发者_C百科lic class CompressionFilterAttribute : ActionFilterAttribute
{
//public override void OnActionExecuting(ActionExecutingContext context)
//{
// HttpRequestBase request = context.HttpContext.Request;
// string acceptEncoding = request.Headers["Accept-Encoding"];
// if (string.IsNullOrEmpty(acceptEncoding))
// return;
// acceptEncoding = acceptEncoding.ToUpperInvariant();
// HttpResponseBase response = context.HttpContext.Response;
// if (acceptEncoding.Contains("GZIP"))
// {
// response.AppendHeader("Content-encoding", "gzip");
// response.Filter = new GZipStream(response.Filter, CompressionMode.Compress);
// }
// else if (acceptEncoding.Contains("DEFLATE"))
// {
// response.AppendHeader("Content-encoding", "deflate");
// response.Filter = new DeflateStream(response.Filter, CompressionMode.Compress);
// }
//}
}
Are you compressing your pages (ie. gzip)? Make sure that your page isn't compressed...
精彩评论