English 中文(简体)
我如何处理申请安保问题? 利用行动基金(FilterAttribute和(或)SomeMap的授权?
原标题:How do I handle application security? using ActionFilterAttribute and/or SiteMap authorization..?

i 创建了以下<代码>ActionFilterAttribute,以检查用户是否获准进入网页。 我还创建了两个处理不同假设情景的海关编码<>Exceptions:NotLobedInExceptionInuffPrivilegeException

<ActionFilterAttribute

Public Class ValidateAuthentication : Inherits ActionFilterAttribute
    Private _page As BLL.Page

    Public Sub New(ByVal Page As BLL.Page)
        Me._page = Page
    End Sub
    Public Overrides Sub OnActionExecuting(ByVal filterContext As System.Web.Mvc.ActionExecutingContext)
        Select Case Me._page.IsAccessibleToUser(filterContext.HttpContext.User)
            Case -1
                Throw New NotLoggedInException()
            Case 0
                Throw New InsufficientPrivilegeException()
            Case 1
                //access granted
        End Select
    End Sub
End Class

我也有一个习俗网站MapProvider,在那里我履行我自己的使命。 因此,我还有安全通道。

<>SiteMapProvider>

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)


    Select case p.IsAccessibleToUser(context.User)
        Case 1
            Return true
        Case else
            Return false
    End Select
End Function

<><>>> 问题:

  1. Where do I catch the exceptions to for instance redirect users if not authorized?
  2. Should I perhaps use the SiteMap authorization somewhere else instead of using the ActionFilterAttribute and throwing Exceptions..?

note: as You can see I m using atom category for BL. 页: 1 这是一个具有功能安全作用的办公室网页,储存在数据库中。 现场普查也根据这一数据进行人口统计。

最佳回答

Do not reinvent AuthoriazeAttribute。 页: 1 如果你需要定制自己的认证,那么就定制了会员提供商或子类<代码>。

问题回答

暂无回答




相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签