public void ProcessRequest(HttpContext context)
{
try
{
// get the resource
Resource resource =
(Resource)CmsHttpContext.Current.Searches.GetByGuid(ResourceGuid);
if (resource != null)
{
HttpCachePolicy policy = context.Response.Cache;
policy.SetLastModified(resource.LastModifiedDate);
policy.VaryByParams["w;h;r"] = true;
Stream stream = resource.OpenReadStream();
// Resize the image
ImageResizer.ResizeImage(
stream,
context.Response.OutputStream,
Width,
Height,
true);
}
else
{
context.Trace.Warn(
"No Image",
"Cannot retrieve resource: "
+ ResourceGuid);
RenderNoImage(context);
}
}
catch (Exception ex)
{
context.Trace.Write(ex.ToString());
Controller.Errors.LogError(ex);
RenderNoImage(context);
}
}
I can get this handler to render effectively for the first few requests. After a few requests, the handler consistently fails to retrieve the Resource and the Searches object may even be null.
2 comments:
I have no clue about how MCMS works but I just wanted to post a comment anyway! I would try removing code and make the handler very simple and see if that makes a difference.
I have experience simiar problems when writing my image resizer.
The reason in my case was low memory situation: I did not release all objects.
In addition the resize class should do an explicit call to the garbage collection as the memory consumption for image operations can be quite high.
Monitor your worker process: around 800 MB is the upper limit for an ASP.NET worker process.
Post a Comment