开发者

Custom Attribute in ASP.NET for Page_Load

开发者 https://www.devze.com 2023-01-19 00:58 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消