title: custom AuthorizeAttribute + custom SiteMapProvider related?
body: <p>I have a custom <code>SiteMapProvider</code> (populated from database) and a custom <code>AuthorizeAttribute</code> (validates current users roles + requested page against Role_Page database) for controller classes.</p>
  
  <p>I have to implement the function <code>SiteMapProvider.IsAccessibleToUser(context, node)</code>. I also have to implement <code>AuthorizeAttribute.AuthorizeCore(context)</code>.</p>
  
  <p><strong>How are these two functions related? Isn't there some way to '<em>attribute</em>' the SiteMapProvider?</strong></p>
  
  <p>Some code:</p>
  
  <hr>
  
  <p><strong>edit:</strong> <strong><em>Might this be a solution (inside <code>AuthorizeCore()</code>)?</em></strong> <em><code>context</code> however is <code>HttpContextBase</code>, and <code>IsAccessibleToUser()</code> only takes <code>HttpContext</code> as parameter.</em></p>
  
  <pre><code>If Not SiteMap.Provider.IsAccessibleToUser(context, SiteMap.CurrentNode) Then
  </code></pre>
  
  <hr>
  
  <p><strong>current code:</strong></p>
  
  <pre><code>Public Class CustomValidateAuthorization : Inherits AuthorizeAttribute
      Public Sub New()
  
      End Sub
  
      Protected Overrides Function AuthorizeCore(ByVal httpContext As System.Web.HttpContextBase) As Boolean
          If Not Global.Page.IsAccessibleToUser(httpContext.User) Then
              //Exception or redirect (in exception)?
              // or return false?
          End If
  
          Return True
      End Function
  End Class
  
  Public Class CustomSiteMapProvider : Inherits StaticSiteMapProvider
  Public Overrides Function IsAccessibleToUser(ByVal context As System.Web.HttpContext, ByVal node As System.Web.SiteMapNode) As Boolean
      Dim p As New BLL.Page
      p.LoadFromSiteMapNode(node)
  
      Return p.IsAccessibleToUser(context.User)
  End Function
  End Class
  </code></pre>