"ArgumentOutOfRangeException" error appears when using unpublishable media items


Description

Sitecore Client might fail to display an image for a media item with publishing restrictions. The issue occurs if the Valid to or Unpublish field value is set to a date in the past.

The following error appears in the field of a media item in the Content Editor and in the log records:

Exception: System.ArgumentOutOfRangeException
Message: Specified argument was out of the range of valid values.
Parameter name: delta
Source: System.Web
at System.Web.HttpCachePolicy.SetMaxAge(TimeSpan delta)
at System.Web.HttpCachePolicyWrapper.SetMaxAge(TimeSpan delta)
at Sitecore.Resources.Media.MediaRequestHandler.SendMediaHeaders(Media media, HttpContextBase context)
at Sitecore.Resources.Media.MediaRequestHandler.DoProcessRequest(HttpContext context, MediaRequest request, Media media)
at Sitecore.Resources.Media.MediaRequestHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Solution

To resolve the issue, consider one of the following options: