title: Umbraco media uploading error 500 because HttpContext is null
body: <p>I was using Umbraco version 7.4.3 for my client's company profile website with blog post functionality. A blog post need to include images in its content body, so I uploaded it as Media node in umbraco. At first it works well, anyone with permission could upload new media either via main menu (on the left) or within wysiwyg editor toolbar.</p>
  
  <p>Then my client told me they were unable to add new images. I looked it up and this was my attempt uploading new image from editor: 
  <a href="https://i.stack.imgur.com/El6lA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/El6lA.png" alt="screenshot"></a></p>
  
  <p>If we look at returned response, it says (omitted):</p>
  
  <blockquote>
    <p>Value cannot be null. 
    Parameter name: HttpContext", "ExceptionType":"System.ArgumentNullException","StackTrace":"   at System.Web.HttpContextWrapper..ctor(HttpContext httpContext)
       at Umbraco.Web.SingletonHttpContextAccessor.get_Value()
       at Umbraco.Web.RequestLifespanMessagesFactory.Get()
       at Umbraco.Core.Services.MediaService.Umbraco.Core.Services.IMediaServiceOperations.Save(IMedia media, Int32 userId, Boolean raiseEvents)
       at Umbraco.Web.Editors.MediaController.d__1b.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---</p>
  </blockquote>
  
  <p>After digging into source code of umbraco, I assumed the <code>HttpContext.Current</code> used is returning null when serving <code>PostAddFile</code>. All references I read said it can only be null if the thread processing is not the main thread or is a background process, thus didn't have HttpContext present. My knowledge on how Umbraco works is limited, so I couldn't think of any solution other than trying re-install it and migrate all data and modification, which is a solution I try to avoid if possible.</p>
  
  <p>Do anyone have suggestion on this problem?
  thanks</p>
  
  <p><strong>Update</strong>:
  My friend found alternative way to upload image, it was using "Action" feature (right sidebar) on Media page. It seems uploading using ajax call caused the error.</p>