Deny callers in the call chain the ability to access the resource specified by the current permission object. This method prevents callers from accessing the protected resource even if they have been granted permission to access it.
[Visual Basic] Overridable Public Sub Deny() [C#] public virtual void Deny(); [C++] public: virtual void Deny(); [JScript] public function Deny();
The Deny method can be used to limit the liability of the publisher or to prevent accidental security holes because it prevents the method that calls Deny from being used to access the resource protected by the denied permission. If a method calls Deny on a permission, and if a security check for that permission is subsequently invoked by a downstream caller in the call chain, that security check will fail.
The call to Deny is effective until the calling code returns to its caller or until a subsequent call to Deny renders the earlier Deny ineffective. Also, RevertDeny or RevertAll will remove a pending deny. Deny is ignored for permissions not granted since a demand for those permissions would fail in any case.
Notes to Implementers: You cannot override this method.
CodeAccessPermission Class | CodeAccessPermission Members | System.Security Namespace