【问题标题】:asp.net web services(.asmx) authorization for particular method特定方法的 asp.net Web 服务(.asmx)授权
【发布时间】:2014-07-17 10:05:28
【问题描述】:

我想创建一个有 2 个方法并且应该被 2 个客户端访问的 Web 服务。 1. 第一个客户端应该能够访问这两种方法。 2. 第二个客户端应该只能访问一种方法。

我怎样才能做到这一点?

【问题讨论】:

  • 您是在谈论授予 .asmx 文件的权限还是仅授予 .asmx 中的一个方法?
  • 仅授予 .asmx 中特定方法的权限

标签: c# asp.net .net web-services asmx


【解决方案1】:

对于第二种方法,再添加 1 个参数(authenticationKey),如果密钥数学则返回数据,否则显示消息无效密钥。

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

【讨论】:

  • 我认为 == "CSCdk33792" 只是一个存根一些适当安全性的示例?
  • 是的,“CSCdk33792”只是一个示例键。我们可以设置我们的密钥。
猜你喜欢
  • 2016-06-21
  • 1970-01-01
  • 1970-01-01
  • 2017-05-14
  • 1970-01-01
  • 1970-01-01
  • 2012-10-13
  • 2013-08-24
  • 2013-10-09
相关资源
最近更新 更多