How many configuring filters level are available in MVC?
You can configure your own custom filter into your application at following three levels:
Global level
By registering your filter into Application_Start event of Global.asax.cs file with the help of FilterConfigclass.
By putting your filter on the top of the controller name as shown below.
By putting your filter on the top of the action name as shown below.
Global level
By registering your filter into Application_Start event of Global.asax.cs file with the help of FilterConfigclass.
Protected void Application_Start() { FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); }Controller level
By putting your filter on the top of the controller name as shown below.
[Authorize(Roles = "Admin")] Public class AdminController : Controller { // }Action level
By putting your filter on the top of the action name as shown below.
Public class UserController : Controller { [Authorize(Users = "User1,User2")] Public ActionResult LinkLogin(string provider) { // TODO: return View(); } }
How many configuring filters level are available in MVC?
Reviewed by Bhaumik Patel
on
10:22 AM
Rating: