Search code examples
c#asp.net.netweb-servicesasmx

asp.net web services(.asmx) authorization for particular method


I want to create a web service which has 2 methods and should be accessed by 2 clients. 1. First client should be able to access both the methods. 2. 2nd client should be able to access only one method.

How can I achieve this?


Solution

  • For 2nd Method add 1 more parameter (authenticationKey) and if key math then return data else show message Invalid key.

    public string Method2(int ClientId, string authenticationKey)
    {
       if(authenticationKey == "CSCdk33792")
       {
         ...
       }
       else
       {
          return "Invalid authenticationKey";
       }
    }