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 chan开发者_如何学JAVAged/>
}
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?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 ;-)
Turbine doesn't add any compression to your application, so that's a different issue.
However, for the Application_Start method, you should not call it within your static constructor.
What you should do instead is override the Startup method and perform any logic here. However, this will not give access to the IServiceLocator you've configured for the application. If you need the IServiceLocator, override the PostServiceLocatorAcquisition method, the can use the ServiceLocator property to have access to it.
I hope this helps!
精彩评论