In MVC Project, How Do You Implement Action Filters in Your Project ? [Resolved]

Posted by KASANI007 under Interview Questions on 6/14/2014 | Points: 10 | Views : 2208 | Status : [Member] | Replies : 4
In MVC Project, How Do You Implement Action Filters in Your Project ?




Responses

Posted by: Goud.Kv on: 6/14/2014 [Member] [MVP] Gold | Points: 50

Up
0
Down

Resolved
Hi,

Action Filter is an attribute which implements FilterAttribute class. ActionFilters in MVC are HandleError, OutputCache, ValidateInput, Authorize, ValidateAntyForgeryToken. Every one has its own functionality.

Implementation:
This is how to implement Action Filters,

[HandleError]
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Message = "Welcome to MVC";

return View();
}

public ActionResult About()
{
return View();
}
}


Hope this helps you.

Thanks & Regards,
Krishna

KASANI007, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Goud.Kv on: 6/16/2014 [Member] [MVP] Gold | Points: 50

Up
0
Down

Resolved
Hi.,

Action filter in MVC application is used to perform some additional processing, such as providing extra data to the action method, inspecting the return value, or canceling execution of the action method.
Action filter is an attribute that implements the abstract FilterAttribute class.

For more details, Go through below links,
http://www.codeproject.com/Articles/577776/Filters-and-Attributes-in-ASPNET-MVC
http://www.dotnet-tricks.com/Tutorial/mvc/b11a280114-Understanding-ASP.NET-MVC-Filters-and-Attributes.html


Thanks & Regards,
Krishna

KASANI007, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 6/16/2014 [Member] [MVP] Platinum | Points: 50
Posted by: Kasani007 on: 6/14/2014 [Member] Starter | Points: 25

Up
0
Down
thanQ Krishna for your reply...can you give some more explanation..?

KASANI007, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response