Asp Net MVC Authentication Extending AuthorizeAttribute

2

I'm doing authentication extending AuthorizeAttribute, I have two doubts, in my DDD application, am I going to create this class in DAL? And how do I leave this global class to use on all controllers?

    
asked by anonymous 31.07.2015 / 16:24

1 answer

2

I'm assuming you'll use C # in the solution.

Modify the following in the file Global.asax.cs :

public class MvcApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
        GlobalFilters.Filters.Add(new MeuAuthorizeAttribute()); // Aqui
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
    }
}

With this, all Controllers and their respective Actions will go through your custom Authorize .     

31.07.2015 / 16:32