I'm building a new site's authentication layer. For user authentication we are using custom platform logic and windows authentication to get user access to the site.

I am looking at pros and cons of implementing this using custom attribute in MVC or implementing in Global.asax Application_Begin Request .

Any ideas on best standard approach

Here is what i'm thinking if i have to go with custom attribute-

public class UserAuthorizeAttribute : AuthorizeAttribute
{
    public UserAuthorizeAttribute()
    {
        //
    }

    protected override bool AuthorizeCore(HttpContextBase httpContext)
    {
        if (!httpContext.User.Identity.IsAuthenticated) return false;
        // Additional Custom Logic 
        return false;
    }
}

Thankyou

Related posts

Recent Viewed