Monday, June 6, 2011

Usage of filters in AsyncControllers

Hi,

Today i would like discuss about usage of filters in AsynControllers.

Filters such as [Authorize], [OutputCache], [ActionName] ,[AcceptVerbs] should be kept on top of ActionAsycn () method than ActionCompleted(). By mistakley if you keep the filter on top of ActionCompleted() – then it will be ignored

Now i would like to discuss one more important aspect, when we use ActionName along with the Asycn Methods. Then also we need to share the same prefix for the method name, i.e ActionAsycn and ActionCompleted.
One small twist, when we use the ActionName filte for any method, as usual the url should follow the ActionName path than the method name,
for instance,
[ActionName(“Path”)]
public void SampleAsync()
{
}

public ActionResult SampleCompleted()
{
}

the request like – http://localhost//Sample – will result into Http 404.

The real path is – http://localhost/Path .

One more last thing, as you know the view name should be Path.aspx than Sample.aspx.

I hope this helps.

Regards,
-Vinayak

No comments: