Fixes exception when DnnImageHandler returns a cached response #3873
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3872
Summary
This error occurs when the image was already generated by
DnnImageHandler
in a previous request and now it's cached in the~\App_Data\_imagecache
folder.A quick workaround is to switch server cache off, in the web config:
but then of course all images are re-generated everytime.
As explained here and here, the problem is that the
System.Web.HttpResponseWrapper.TransmitFile(string)
method, followed byResponse.End()
produces the exception mentioned in #3872.This sequence can be seen in code, in following lines:
Dnn.Platform/DNN Platform/Library/Services/GeneratedImage/DiskImageStore.cs
Line 291 in 1bb11bf
Dnn.Platform/DNN Platform/Library/Services/GeneratedImage/ImageHandlerInternal.cs
Line 257 in 1bb11bf
Replacing
Response.End()
withResponse.Flush()
fixed the issue.