A: 

Not exactly sure what you are looking for, but if you throw an SPException you have greater control over the contents of the error page.

Todd Friedlich
+6  A: 

You should be able to use SPUtility.HandleAccessDenied to do this. (You can pass in null for the exception parameter if you just want to force the Access Denied page to be displayed, but aren't actually handling an exception.)

DylanW
A: 

Depending on what you're doing, you should be able to do this by configuring the permissions on your site correctly. If you have a page that you don't want certain users to be able to view, that page's permissions should be set up accordingly.

If this is something you're trying to do in code from some sort of event handler or another, though, you may need a different solution. There may be a specific SharePoint exception for this, but I don't know what it is off-hand.

I guess the real question is, what exactly are you trying to do that you want to block access to?

Jonathan Schuster