Ben baz sayfa yaklaşım sevmiyorum. Bana göre güvenlik konularını kontrol etmek için çok geç. Kendi HttpModule'ınızı oluşturarak, yetkilendirme bilgilerinin bir veritabanında/xml/... içinde saklanmasını veya sayfadaki yansımayı kullanarak okuduğunu kontrol edebilirsiniz.
context.Handler, yürütmekte olduğunuz sınıf sayfasını tutacaktır. Böylece böyle bir şey yapabilirsiniz:
kullandığım kod parçası kopyalama, o rolleri, kamu sayfaları kontrol eder resimler ve komut dosyaları (ama siz de bunu yapabilirdi) için onay atlar:
// In the HttpModule:
public void context_PreRequestHandlerExecute(object sender, EventArgs e)
{
HttpContext context = HttpContext.Current;
// Don´t validate permissions if the user wasn´t allowed by the asp.net security
// Neighter the advanced (custom) permissions are validated for non ASPX files.
if (!context.Request.FilePath.EndsWith(".aspx") || !context.User.Identity.IsAuthenticated)
return;
// Give full access to the unathorized error page, and logins, and so on...
string pageClass = context.Handler.GetType().BaseType.FullName;
string param = context.Request["p"];
if (!string.IsNullOrEmpty(param))
pageClass += "@" + param;
if (SecurityService.IsFullTrustClass(pageClass))
return;
if (SecurityService.Context.CurrentPerson == null)
{
LogOff();
return;
}
// Verify access permissions for the current page
IList<Role> roles = SecurityService.Context.CurrentPerson.Roles;
bool allow = SecurityService.HasAccessPermission(pageClass, roles);
if (!allow)
{
LogOff();
}
}