Asp Net MVC Authentication Extending Authorizeattribute

Asked

Viewed 173 times

2

I am doing authentication extending Authorizeattribute, I have two doubts, in my DDD application, I will create this class in DAL? And how I leave this global class to use on all controllers?

1 answer

2


I’m guessing 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 the Controllers and their respective Actions will pass through your Authorize customized.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.