moonpyk / mvcdonutcaching

ASP.NET MVC Extensible Donut Caching brings donut caching to ASP.NET MVC 3 and later. The code allows you to cache all of your page apart from one or more Html.Actions which can be executed every request. Perfect for user specific content.
https://github.com/moonpyk/mvcdonutcaching
MIT License
142 stars 49 forks source link

Sometimes the cached page becomes blank page. #16

Open chancewen opened 10 years ago

chancewen commented 10 years ago

I use mvcdonutcaching on one page of my site. It runs well except that sometimes the page becomes blank page, so that I must restart IIS to recover. the problem happens every a few days.

I wonder if this problem is related to mvcdonutcaching.

Thanks a lot!

moonpyk commented 10 years ago

We need more details to investigate on this issue.

JohanAlkemade commented 10 years ago

We are experiencing the same. For now I can only add that we see that if you refresh the page the problem disappears. Maybe we are experiencing a different bug, but seems to me it's related. I try to get some more details. We are using the library in a webfarm like environment where we have set the machinekey to be the same on all the machines.

JohanAlkemade commented 10 years ago

I couldn't reproduce this, but after looking at the code it might be a threading issue. In the ExecuteCallback (which is stored in the HttpContext), the library uses a variable "cachingWriter" which is set as the output writer before the result is executed. The code results in a closure.

Now I don't know how .NET compiles closures, but could it perhaps be that if one thread calls the cachingWriter.toString() and another thread just created a new cachingWriter, the first call results in a empty string as it is a new StringWriter?

moonpyk commented 10 years ago

I don't what to answer actually, in normal conditions ASP.NET MVC handles each request on a separate thread and sticks to it. If it's not the case, I clearly don't know what to do.

YodasMyDad commented 10 years ago

I'm guessing in this case, that this project won't work when using Async Controllers in MVC4 onwards?

http://www.codeguru.com/csharp/.net/net_asp/mvc/creating-asynchronous-actions-in-asp.net-mvc.htm

moonpyk commented 10 years ago

We don't have any update on this, we have projects using async controllers in production, who, of course make use of MvcDonutCaching with no problem. Added that, since MVC4 all controller internal infrastructure is async by default.

YodasMyDad commented 10 years ago

Fantastic :) This is an excellent project.

Sebosek commented 9 years ago

Actually we have similar issue - sometimes is page just empty. Should we rewrite controller actions to async, or why @leen3o mention it?

Jogai commented 5 years ago

I had it too. Running on azure. Problem is, the status code is still OK, so my monitors dont alert me...

jecabana commented 3 years ago

In my case I found that removing this line fixed my issue,
"ControllerContext.RequestContext.RouteData.Values.Remove(value.Key);" there should be some problems removing values from ControllerContext.RequestContext.RouteData that cause that the page become a blank page without throwing any error. PD: If you add the removed value after removing it, that also fix the issue, like this ControllerContext.RequestContext.RouteData.Values.Add(value.Key, value.Value);