Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Configuring Filters in MVC

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 58
    Comment on it

    Filters in MVC needs to be configured when you need something other to be done which is not provided by its member or methods.

     

    You can configure your own custom filter by the following three ways :

    (1)  Global level

    By registering your filter into the Application_Start event of Global.aspx.cs class with the help of action filter.

     

        protected void Application_Start()
        {
         FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        }

     

    (2) Controller level

    By putting your filter on top of the controller name.

     

    Authorize(Roles="Admin")]
    public class AdminController : Controller
    {
     //
    }

     

    (3) Action Level 

    By putting your filter on top of the action.

     

        public class UserController : Controller
        {
         [Authorize(Users="User1,User2")]
         public ActionResult LinkLogin(string provider)
         {
         // TODO:
         return View();
         }
        }

     

    .net

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: