开发者

How to use a vb.net module in asp mvc view

The module containts of a bunch of string properties like:

Public Module RolRechten
    Private ReadOnly _DienstenRecht = "Beheer diensten"
    Public ReadOnly Property Di开发者_如何学GoenstenRecht() As Object
        Get
            Return _DienstenRecht
        End Get
    End Property

how do you acces this module in your view ?

If Page.User.IsInRole("Beheer diensten") Then

The goal is to prevent typo's all around the application and if someone for some unknown reason wants to change the description of a role we don't have to check every if.


You could import the namespace and then use it:

@Imports AppName

@Code
    If User.IsInRole(RolRechten.DienstenRecht) Then

    End If
End Code

Also notice that I am using User.IsInRole. Page.User.IsInRole is classic web forms and chances are it will crash in Razor.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜