views:

157

answers:

3

As the title said, I need to raise (from the C# code behind a custom SharePoint page) a 401 error page. Any help?

A: 

Kindly refer the link below,

http://www.codeproject.com/KB/sharepoint/Errorhandling_in_Webparts.aspx

solairaja
+3  A: 

Try this:

throw new HttpException(401, "Unauthorized access");
Rubens Farias
+1  A: 

If the exception is SharePoint related it's best to throw a SharePoint exception

throw new SPException("Not Authorized");

See also http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spexception.aspx

W0ut