Try our conversational search powered by Generative AI!

Created content folder/assets folder doesn't appear in Asset Pane


When an editor is uploading an image, a new folder is created in a specific directory (a sub-directory in another sub-directory of the root folder) and different sizes of the image are created and stored in the folder.

My problem is that I will not see the folder in the asset pane unless I reload the page. I am wondering what part of the code is messing up or if it is the location that I am trying to create the new folder.

            var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();

            //where new Models.Media.ImageFile().MediaFolder is the content reference of folder that the new folder should be created
            var contentAssetFolder = contentRepository.GetDefault<ContentAssetFolder>(new Models.Media.ImageFile().MediaFolder);

            contentAssetFolder.Name = content.Name.Substring(0, Path.GetExtension(content.Name).Length) + "_" + System.DateTime.Now.ToString("M-d-yy");
            return contentRepository.Save(contentAssetFolder, SaveAction.Publish, AccessLevel.NoAccess);
Edited, Aug 21, 2019 23:51

If it appears after reload, it's probably correct code but that the tree structure in assets pane is cached until you do a full reload of page?

Not sure how to invalidate that cache though. 

Aug 23, 2019 10:53

Hmm, I think I will refresh the cache after the folder is created just to see whether or not this is the problem.

Aug 23, 2019 16:50

Hi Ben,

Yes, A full reload is required after adding and removing anything using code in the Episerver CMS.



Aug 24, 2019 10:06

While I am still working on the cache refresh, hey Ravindra can you explain why the page needs to be refreshed! It would help me find a way around this situation.

Aug 26, 2019 17:07

Hi Ben,

Episerver uses the Dojo JavaScript framework for the CMS UI and when you add or delete anything from code behind that basically adding the entries in the database and to view these new items in CMS you basically need to make a CMS data update call.

And I think refreshing the page will do the same for you.

Aug 27, 2019 8:12

Hey Ravindra,

Yep, I came to the same conclusion about having to use Dojo. I was just unclear how the server-side communicated with the UI, if it is via the database then I should be halfway there on developing a solution. Thanks, Ravindra, if you have an example of a simple update then that would help as well!

Aug 27, 2019 16:02

Great post. It was much needed. Love your simplistic style of explanation. :)

Sep 02, 2019 11:33

Thanks, Jane

When I finally develop a solution I will post it here, but in the meantime know that the Dojo direction is most likely the right one. Just need to figure out how the backend and Dojo communicates' and if it is event-driven.

Sep 03, 2019 17:15
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.