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?
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?
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 .