Try our conversational search powered by Generative AI!

Exception thrown in EPiServer.Cms.Shell.Service.Internal.ContentService.SaveMedia


Hi all, 

When we replaced an image in the CMS, we kept seeing an error:

"Timed out, or max file size exceeded"

We investigated all the solutions available online, but nothing worked. 

Eventually we decompiled your code and found that an exception is thrown when you try to cast IContentMedia to IContent:

This only happens when we replace an image. Not when we upload a new image. 

Steps to reproduce: 

  1. Be on Episerver 11
  2. Upload an image
  3. Upload an image with the same name


Image should upload with no error


"Timed out, or max file size exceeded"

Any ideas on a solution? 

Edited, Jun 25, 2018 17:20

I can verify that on clean Alloy (v11.7) replace of the image works as expected.

Do you have any custom handlers or anything that might mess around this operation?

Jun 26, 2018 20:17

We removed all custom handlers and the problem persisted. In the end, we circumvented the issue by adding cache-busting so each image name was unique and avoided the rename issue. 

Jul 11, 2018 12:39
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.