You thought about calling the action controller method asynchronously, even with the ability to call a new thread to save the document so that the web page does not expect a response and does not risk a timeout.
Use jquery ajax call to call your controller and parallel task library to save the document. An ajax call might do something with a success / failure handler called after receiving a response.
It looks something like this
$(function() { $('selector').click(function() { var id = $('selector for id').val() $.ajax({ type: "POST", url: "/Controller/VideoUpload", data: { memberId: id }, contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { $("selector for status").(msg); }, }); }); });
The method of action will look something like this, although it may be inaccurate. You do not have to do this, as the ajax message should allow the method call to execute without a browser waiting for a response.
[HttpPost] public ActionResult VideoUpload(int memberId) { var status = Task.Factory.StartNew(() => _docRepo.SaveDocument(DocumentType.Video, Request.Files, memberId)); return Json(new { success = true, status = status.Result}); }
source share