我已经在ASP.Net中创建了一个身份验证模块,但是我不希望在验证模块中的逻辑被执行,如果资源配置为匿名访问,因为逻辑很贵。Asp.Net身份验证模块
有些页面需要在不需要认证的页面的同一目录中进行认证。我无法控制这一点。有没有简单的方法来确定资源配置为允许在URLAuthorizationModule之前进行匿名访问?
目前,我正在做的“感觉”是正确的以下内容。任何帮助,将不胜感激。
public static bool AllowEveryone()
{
bool rslt = false;
AuthorizationSection config = (AuthorizationSection)WebConfigurationManager.GetSection("system.web/authorization");
if (config.Rules != null && config.Rules.Count > 0)
{
AuthorizationRule r = config.Rules[0]; //doing this based on implementation of urlauthorization module in reflector...
if (r.Action == AuthorizationRuleAction.Allow && r.Users.Contains("*"))
{
return true;
}
//todo: check for allow anon ? case
}
return rslt;
}
对不起,我不清楚。该页面已根据您的描述进行配置。但是,我有一个自定义身份验证模块。如果页面配置为允许用户=“*”或允许用户=“?”,我想在知道用户身份之前退出模块逻辑。 – complexcipher 2009-07-28 15:01:24