VB.NET - Discuss about imperative and declarative security

Discuss about imperative and declarative security.

Declarative security : Security requests are made in form of attributes.

Example:
<MyPermission(SecurityAction.Demand, Unrestricted = True)>
Public Class MyCustomClass
    Public Sub New()
            'The constructor is protected by the security call.
    End Sub
    Public Sub Method1()
            'This method is protected by the security call.
    End Sub
    Public Sub Method2()
            'This method is protected by the security call.
    End Sub
End Class

Imperative security : Security requests are made in the form of lines of code within a method body.Basically an instance of permission object is created that needs to be invoked.

Example:
Public Class MyCustomClass
    Public Sub New()
    End Sub
    Public Sub Method1()
            'MyPermission is demanded using imperative syntax.
            Dim permission As New MyPermission()
            permission.Demand()
            'This method is protected by the security call.
    End Sub
    Public Sub Method2()
            'YourMethod 'This method is not protected by the security call.
    End Sub
End Class
VB.NET - How do we access crystal reports in .NET?
How do we access crystal reports in .NET? - Add a new web project......
VB.NET - Steps to add a control to a form at run time
Steps to add a control to a form at run time - create and initialize a control.....
VB.NET - Explain how to retrieve information from the configuration file at run time.
Retrieve information from the configuration file at run time
Post your comment