Custom Attribute in ASP.NET for Page_Load
I have an ASP.NET 3.5 Site where, in some places, I am checking if the currently logged on Active Directory user is in a certain AD Security Group. In the Page_Load I'm doing something like this:
if (isInADGroup(UserGUID))
{
//proceed
}
Now I was wondering, couldn't I just create a Custom Attribute, like some of MVC's s开发者_运维知识库ecurity attributes, which runs this check and cancels the execution or displays an error message?
Not sure about an attribute but you could always create a custom page that handles this inheriting from System.Web.UI.Page and use this as the base class for your web forms.
精彩评论