Thursday, February 10, 2011

Best practice for Async with ASP.net MVC 2?

As of ASP.net MVC 2 RC, there have been Async Controller available. There also various of ways and practice to make the async Controller.

For example:

  1. http://msdn.microsoft.com/en-us/library/ee728598(VS.100).aspx
  2. http://www.ducdigital.com/2009/12/24/builtin-async-controller-in-asp-net-mvc-2/
  3. http://weblogs.asp.net/seanmcalinden/archive/2009/11/15/asynchronous-processing-in-asp-net-mvc-with-ajax-progress-bar.aspx

for the first one, it is good to separate the module service with the controller, but there are some problem with the length to just do a method. For example, i want to have 2 method, which process differently and have different input like:

public void Test(string a) public string Test(string a, string b)

I will have to end up rewrite everything (IMO).

for the 2nd, it's good, and fast to write, we can easily turn a normal method into a Async method. But it might be not a good solution in some way.

What's your suggest of doing async controller. I could prioritize the shortness of a code (shorter = less bug), and also the one that can easily write as class module / plugin class (separate from main MVC code)

Please give your best advice :)

0 comments:

Post a Comment