Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

WebPermission.IsSubsetOf Method

Determines whether the current WebPermission is a subset of the specified object.

Namespace:  System.Net
Assembly:  System (in System.dll)

Public Overrides Function IsSubsetOf ( _
	target As IPermission _
) As Boolean


Type: System.Security.IPermission

The WebPermission to compare to the current WebPermission.

Return Value

Type: System.Boolean
true if the current instance is a subset of the target parameter; otherwise, false. If the target is Nothing, the method returns true for an empty current permission that is not unrestricted and false otherwise.




The target parameter is not an instance of WebPermission.


The current instance contains a Regex-encoded right and there is not exactly the same right found in the target instance.

If the current WebPermission specifies a set of associated resources that is wholly contained by the target parameter, then the current WebPermission is a subset of target. This method overrides IsSubsetOf and is implemented to support the IPermission interface.

The following example uses IsSubsetOf to determine whether the access rights found in one instance of WebPermission are found in another instance of WebPermission.

      ' Create the target permission. 
      Dim targetPermission As New WebPermission()
      targetPermission.AddPermission(NetworkAccess.Connect, New Regex("www\.contoso\.com/Public/.*"))

      ' Create the permission for a URI matching target. 
      Dim connectPermission As New WebPermission()
      connectPermission.AddPermission(NetworkAccess.Connect, "www.contoso.com/Public/default.htm")

      'The following statement prints true.
      Console.WriteLine(("Is the second URI a subset of the first one?: " & connectPermission.IsSubsetOf(targetPermission)))
   End Sub 'myIsSubsetExample

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft