Search code examples
c#asp.net-mvcrefactoringturbine

Why does my http response body suddenly contain a load of gibberish?


I'm trying to refactor an existing asp.net-mvc web application and introduce mvc-turbine.
The application works as is, but I want to make it more pluggable and maintainable so future maintenance will be easier.

I figured I'd try to keep the refactoring steps as small as possible, so I referenced MvcTurbine, MvcTurbine.Unity and MvcTurbine.Web.
Then I made my MvcApplication in global.asax.cs look like this:

Public class MvcApplicatoin : TurbineApplication{
    static MvcApplication(){
        ServiceLocatorManager.SetLocatorProvider(() => new UnityServiceLocator());
        Application_Start();
    }
    <snip of all code that hasn't changed/>
}

I realize calling Application_Start is not how it's supposed to go, but that would keep the changes for the first step as small as possible.
When I now run, I see the code in my controller gets hit and runs correctly. Then my views are being rendered. I can step through each line, no problems there either. And then the result gets shown in the browser: gibberish.
������í½I%&/mÊ{JõJ×àt¡$Ø@ìÁÍæìiG#)«*ÊeVe]f@Ìí¼÷Þ{ï½÷Þ
etc, a whole page of that.

I didn't encounter this problem without Turbine nor did I encounter any problems in previous tests where I would introduce Turbine from the start.
Any ideas on how I can start to debug this?


Solution

  • I'd say that somehow you're gzipping the output twice. Check out Response.Filter and HttpModules loaded after Application_Start() is called from your .cctor and after it's called from the ASP.NET engine.

    Alternatively, make sure you have the Klingon fonts installed ;-)