开发者

How to raise a 401 (Unauthorized access) exception in Sharepoint?

开发者 https://www.devze.com 2022-12-08 21:02 出处:网络
As the title said, I need to raise (from the C# code behind a custom SharePoint page) a 401 error page. Any 开发者_如何学Chelp?Try this:

As the title said, I need to raise (from the C# code behind a custom SharePoint page) a 401 error page. Any 开发者_如何学Chelp?


Try this:

throw new HttpException(401, "Unauthorized access");


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


return new HttpUnauthorizedResult();


try this:

throw new UnauthorizedAccessException($"Some message");
0

精彩评论

暂无评论...
验证码 换一张
取 消