I'm using umbraco to perform some actions against the API in my MVC controller action following a form submit. All works fine.
The code uploads a new image, adds it using the MediaService, and then removed the previous image using the MediaService.
I've just got to the point where I've implemented the removal logic, where I call :
public bool DeleteMediaItem(Uri mediaItemUri)
{
if (mediaItemUri == null)
{
return false;
}
var mediaService = UmbracoContext.Current.Application.Services.MediaService;
var mediaItem = mediaService.GetMediaByPath(mediaItemUri.ToString());
if (mediaItem == null)
{
return false;
}
mediaService.Delete(mediaItem);
return true;
}
If I comment out the line mediaService.Delete(mediaItem); then all works fine. However when left in, subsequent HTTP requests against my site have an empty ASP.NET Session.
I'm doing something very similar I get this issue too, using version 7.3.3. Were you able to get a work around on this issue?
For the time being I had to use .MoveToRecycleBin, i.e. in your case
mediaService.MoveToRecycleBin(mediaItem);
Not exactly ideal as it means it will require someone to empty out the recycle bin every now and again, or create a timed event that regularly empties it.
MediaService.Delete Clears ASP.NET Session
Hi All,
I'm using umbraco to perform some actions against the API in my MVC controller action following a form submit. All works fine.
The code uploads a new image, adds it using the MediaService, and then removed the previous image using the MediaService.
I've just got to the point where I've implemented the removal logic, where I call :
public bool DeleteMediaItem(Uri mediaItemUri) { if (mediaItemUri == null) { return false; }
}
If I comment out the line mediaService.Delete(mediaItem); then all works fine. However when left in, subsequent HTTP requests against my site have an empty ASP.NET Session.
Is this a known issue?
Thanks,
Dan
I'm doing something very similar I get this issue too, using version 7.3.3. Were you able to get a work around on this issue?
For the time being I had to use .MoveToRecycleBin, i.e. in your case
Not exactly ideal as it means it will require someone to empty out the recycle bin every now and again, or create a timed event that regularly empties it.
B.
is working on a reply...