We are implementing async controllers in ASP.NET MVC4 using tasks. If the task fails the worker process crashes with something like this:
Exception: System.AggregateException
Message: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread.
I think you are hitting
this bug of ASP.NET MVC 4 beta.
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Are you saying that this is by design and we should catch all errors and return error view in this case?
it is very poor practice for async tasks to throw errors. they should return an exception status. if you are running a true async task, the thread may be performing an operation for another request when the error is throw. this is just ugly to manage. .net
changed thread pools to eat exceptions (except thread abort) due to simular problems.
alexivanoff
0 Points
10 Posts
UnobserverTaskException with async controller
Apr 19, 2012 12:13 AM|LINK
We are implementing async controllers in ASP.NET MVC4 using tasks. If the task fails the worker process crashes with something like this:
Looks like a bug or are we missing something?
CodeHobo
All-Star
18647 Points
2647 Posts
Re: UnobserverTaskException with async controller
Apr 19, 2012 12:26 AM|LINK
Are you actually using the AsyncController base class? What does your controller look like?
Blog | Twitter : @Hattan
ignatandrei
All-Star
135087 Points
21669 Posts
Moderator
MVP
Re: UnobserverTaskException with async controller
Apr 19, 2012 03:05 AM|LINK
And this is normal.What would you do the task execution to do in error case?!
I would surrender the task execution with try/catch and log the errror.
alexivanoff
0 Points
10 Posts
Re: UnobserverTaskException with async controller
Apr 19, 2012 06:30 PM|LINK
public class HomeController : Controller { public Task<ViewResult> Index() { return <task that faults>; } }alexivanoff
0 Points
10 Posts
Re: UnobserverTaskException with async controller
Apr 19, 2012 06:31 PM|LINK
Are you saying that this is by design and we should catch all errors and return error view in this case?
CodeHobo
All-Star
18647 Points
2647 Posts
Re: UnobserverTaskException with async controller
Apr 19, 2012 06:34 PM|LINK
You should really consider using the asynccontroller instead of just controller. It was built for this kind of scenario.
http://msdn.microsoft.com/en-us/library/system.web.mvc.asynccontroller.aspx
Check out this blog post for more info:
http://www.aaronstannard.com/post/2011/01/06/asynchonrous-controllers-ASPNET-mvc.aspx
Blog | Twitter : @Hattan
alexivanoff
0 Points
10 Posts
Re: UnobserverTaskException with async controller
Apr 20, 2012 05:25 PM|LINK
In ASP.MET MVC 4 beta AsyncController "Provided for backward compatibility with ASP.NET MVC 3."
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: UnobserverTaskException with async controller
Apr 22, 2012 10:49 AM|LINK
I think you are hitting this bug of ASP.NET MVC 4 beta.
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
alexivanoff
0 Points
10 Posts
Re: UnobserverTaskException with async controller
Apr 23, 2012 09:38 PM|LINK
So, is this by design or should I report a bug?
bruce (sqlwo...
All-Star
36852 Points
5446 Posts
Re: UnobserverTaskException with async controller
Apr 24, 2012 03:26 AM|LINK
it is very poor practice for async tasks to throw errors. they should return an exception status. if you are running a true async task, the thread may be performing an operation for another request when the error is throw. this is just ugly to manage. .net changed thread pools to eat exceptions (except thread abort) due to simular problems.