【问题标题】:Building .NET WCF service for iPhone with authentication使用身份验证为 iPhone 构建 .NET WCF 服务
【发布时间】:2013-08-05 18:08:57
【问题描述】:

尝试创建一个非常简单的宁静 WCF 服务,它将为 iPhone 应用程序提供数据。

希望使用某种基本身份验证,最有可能是用户名/密码或某种令牌。

在查找有关该主题的任何好的文档时遇到一些问题,因此非常感谢您的帮助!

干杯, 蒂姆

【问题讨论】:

    标签: iphone .net wcf


    【解决方案1】:

    对于任何感兴趣的人,我通过以下方式解决了这个问题:

    在system.servicemodel下的web.config中:

    <behaviors>
        <serviceBehaviors>
            <behavior name="default">
                <serviceAuthorization serviceAuthorizationManagerType="Your.ServiceAuthorizationManager"></serviceAuthorization>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service name="Your.WCF.Service" behaviorConfiguration="default">
    </services>
    

    然后在您的经理处理中(Your.ServiceAuthorizationManager 类)您可以访问操作上下文中的请求,可以授权并在授权时返回 true,否则返回 false。

    public class Your.ServiceAuthorizationManager : ServiceAuthorizationManager
    {
        protected override bool CheckAccessCore(OperationContext operationContext)
        {
            // Validate request here...
    
            return true;
        }
    }
    
    • 显然复制和粘贴此代码不起作用,您需要在几个地方进行编辑。

    希望对某人有所帮助!

    【讨论】:

      猜你喜欢
      • 2011-01-15
      • 1970-01-01
      • 2012-03-23
      • 2015-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多