Asynchronous and synchronous action methods in the same controller

Is possible to have asynchronous and synchronous action methods in an AsyncController? Is there any drawback doing this?

The reason is that an asynchronous operation makes sense for a time consuming operation, but does not make sense for return a form in HTML.

For example, I have a page that generates a file. The action method that returns the form with the inputs has almost no logic, but the action method that receives the POST, send it to another web service and relay the response takes some time, so it will make sense to do it asynchronously.

I could put those methods in separated controllers, one synchronous and another synchronous, but I would like to keep them together.

Cheers.

--------------Solutions-------------

Is possible to have asynchronous and synchronous action methods in an AsyncController?

Yes.

Is there any drawback doing this?

Not really.

The reason is that an asynchronous operation makes sense for a time consuming operation

time consuming operation and I/O intensive so that you can benefit from I/O Completion Ports. If you have a CPU time consuming operation that you are running in a separate thread you get strictly no benefit from async controllers. At the contrary it will make things worse.

For example, I have a page that generates a file. The action method that returns the form with the inputs has almost no logic, but the action method that receives the POST, send it to another web service and relay the response takes some time, so it will make sense to do it asynchronously.

OK, web service call is an I/O intensive operation => you will get benefit from an async controller. You could have the two actions in this case on the same async controller.

Category:asp.net mvc Time:2011-10-25 Views:1

Related post

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.469 (s). 13 q(s)