Abhijit Pandya
Abhijit Pandya

Reputation: 705

ASP.NET MVC asynchronous file upload using jQuery

I have used this jQuery plugin for upload a file.

It is working fine with single/multiple files.

But when I try to upload large files like 90 to 100 MB in size, it blocks all other ajax calls.

While uploading such large files if I've minimized the window and I am trying to access other page, all ajax calls will be in queue until upload completes.

There isn't any issue with file upload, I can upload a file upto 2 GB. But I can't access any other functionality of my site until the upload completes.

How can I solve this issue ?

I want to force this upload process to work asynchronously, to let me access all other pages/ functionality of my site.

Is there any other option/plugin available which I an use for this purpose (without Flash) ?

Upvotes: 2

Views: 1219

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038880

That's normal and expected behavior if you are using ASP.NET Sessions inside your controller. It is by design. The ASP.NET Session is not thread safe and if you attempt to trigger parallel requests from the same session, ASP.NET will simply block and execute the 2 requests sequentially.

If you don't want this behavior you will have to disable sessions for the controller containing the action you are uploading to. This could be done by decorating it with the SessionState attribute:

[SessionState(SessionStateBehavior.Disabled)]
public class SomeController: Controller
{
    // You cannot use Session in this controller

    [HttpPost]
    public ActionResult Upload(MyViewModel model)
    {
        ...
    }
}

Upvotes: 3

Related Questions