Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
We are using Role based authentication in WCF service like
Admin method:

C#
[PrincipalPermission(SecurityAction.Demand, Role = "Admin")]
       public List<DataModels.BookStatus> ListOfBooks(DataModels.PortalsList PortalsList, DateTime StartDateTime, DateTime EndDateTime, bool BookPublishedStatus, string Username)
       {
           try
           {
               objBookList = objListOfBooks.GetListOfBooks(PortalsList, StartDateTime, EndDateTime, BookPublishedStatus, Username);
               return objBookList;
           }
           catch (SecurityAccessDeniedException)
           {
               throw new FaultException("You can't access admin methods.");
           }
       }


When User accessing this method,Its throwing unhandled SecurityAccessDeniedException. Unable to throw fault exception with "You can't access admin methods" message.

How to handle SecurityAccessDeniedException in my service.

Thanks
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900