Reputation: 5832
We recently ran into the issue where ExecuteCore()
in BaseController was no longer being called. Worked in MVC 3 but not in MVC 4
So, I added the property protected override bool DisableAsyncSupport
to BaseController like so:
protected override bool DisableAsyncSupport
{
get { return true; }
}
The obvious problem now is what to do when we get an async action? How can I detect if the controller action is synchronous VS asynchronous?
I need something like this, I think:
protected override bool DisableAsyncSupport
{
get
{
if(actionIsSynchronous)
return true;
else
return false
}
}
Thanks for helping out!
Upvotes: 3
Views: 910
Reputation: 3869
Instead of using ExecuteCore you can try to use BeginExecuteCore
protected override IAsyncResult BeginExecuteCore(AsyncCallback callback, object state)
{
return base.BeginExecuteCore(callback, state);
}
Another solution could be to override the Initialize method.
protected override void Initialize(RequestContext requestContext)
{
//Put your code here
}
Upvotes: 2