views:

1796

answers:

2

Hi Guys,

I am trying to create an upload control for ASP.NET MVC with jQuery progress bar. In ASP.NET the implementation works no problems, but in MVC the problem is that the server doesn't respond to my callbacks until the file is uploaded.

The upload control is based on html file upload element, and I cannot for the life of me, understand how MVC handles postback + callback synchronously ?

I have searched for a whole bunch of answers, but all I can find is a "callback+callback" solution and NOT a postback+callback.

Does anyone have any idea how to solve this problem for MVC ?

Thanks

+3  A: 

Hrmmm,

Thomas, MVC does not handle post-backs at all. Because a URL is directly routed to an Action method on a controller, a form is not meant to actually post-back to itself. Further more, all of the post back processing that Asp.Net had to handle post-backs on the server was pulled out of the .Net MVC framework.

A better approach to accomplish what you're trying to do with a progress bar would be to use JQuery with AJAX to make the call to your server and then use Javascript/CSS (possibly a lightbox approach) or a pop-up window to inform the user that they are waiting. When the Ajax call completes it's work, you can have Javascript fire the redirect to the page in your MVC that you want the user to be redirected to after the action has been performed. Making AJAX calls with JQuery is a total breeze and is pretty fun to play around with as well!

Check it...

matt_dev
+2  A: 

here you can find a great article on jquery uploader http://blog.codeville.net/2008/11/24/jquery-ajax-uploader-plugin-with-progress-bar/

tartafe