I have AuthorizeAttribute in my old ASP.NET MVC project like this
public class CustomAuthAttribute : AuthorizeAttribute
{
public override void OnAuthorization(AuthorizationContext filterContext)
{
base.OnAuthorization(filterContext);
...
}
}
I want to use this attribute in new site that uses ASP.NET Core MVC Controller/Action.
I have tried to configure in Startup.cs like this
services.AddMvc(options =>
{
options.Filters.Add((new CustomAuthAttribute());
});
But it can not resolve the type IFilterMetadata.
Moreover, I try to use this Attribute in Controller but nothing happens.
[CustomAuth]
public class HomeController : Controller
Anyone can help me? Thank you