Note that there are some explanatory texts on larger screens.

plurals
  1. POCall MVC async action through Ajax, start task, send the ajax response before the task completes?
    primarykey
    data
    text
    <p>I have the following scenario:</p> <p>I have an MVC Async Controller that has an upload action, which processes a csv file and saves the data to the database using nHibernate. This is called using </p> <pre><code> Task&lt;Nacr.Core.Entities.FileLoad.Job&gt;.Factory.StartNew(() =&gt; { _fileUploadService.ProcessJob(job); } }); </code></pre> <p>Currently the action is called thorugh an ajax call, and I am waiting for the ProcessJob to finish before sending back my response to the originating ajax call.</p> <p>I am notifiying the user of the files progress using a signalR notifier hub to populate a record count and progress bar on the UI, which works a treat. Therefore is no need for the ajax call to wait for this to complete, as the results are visible during processing.</p> <p>However, if I close the ajax call after I have started the processJob running, I get the following error:</p> <pre><code> System.ObjectDisposedException: Session is closed! </code></pre> <p>This is due to the fact that the Session is registered with a PerWebRequest lifestyle in Windsor, but my question is is there any way that the session can be used after the ajax call has had a response?</p> <p>The reason for my question is that for very large files, the ajax request appears to be recalling the processJob after around a minute, presumably due to the fact that it has waited for too long without receiving a response for the original request.</p> <p>My original question on this can be viewed here: <a href="https://stackoverflow.com/questions/16215205/async-controller-action-re-called-after-one-minute">Async Controller Action Re-Called after one minute</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload