代码之家  ›  专栏  ›  技术社区  ›  Stilgar

自定义ASP.NET使用WCF表单身份验证服务

  •  1
  • Stilgar  · 技术社区  · 14 年前

    我正在尝试创建一个自定义ASP.NET使用WCF形成身份验证服务。我通过一个只包含一行JS的测试页面调用它(除了ScriptManager脚本)。问题是服务器返回响应代码500,而响应主体为空。我在服务方法和应用程序中的断点出错全球.asax没有被击中。

    Sys.Services.AuthenticationService.login('user', 'pass', false, null, null, null, null, null);
    

    {"userName":"user","password":"pass","createPersistentCookie":false}
    

    请求方的其他事情似乎也不错。

    以下是配置服务:

    <system.serviceModel>
      <behaviors>
        <endpointBehaviors>
          <behavior name="BtxAuthenticationEndpointBehavior">
            <webHttp/>
          </behavior>
        </endpointBehaviors>
        <serviceBehaviors>
        </serviceBehaviors>
      </behaviors>
      <services>
        <service name="MyNamespace.BtxAuthenticationService">
          <endpoint contract="MyNamespace.IBtxAuthenticationService" binding="webHttpBinding" behaviorConfiguration="BtxAuthenticationEndpointBehavior"/>
        </service>
      </services>
    </system.serviceModel>
    

    以及接口声明:

    [ServiceContract]
    public interface IBtxAuthenticationService
    {
        [OperationContract]
        [WebInvoke]
        bool Login(string username, string password, bool createPersistentCookie);
    
        [OperationContract]
        [WebInvoke]
        void Logout();
    }
    

    public class BtxAuthenticationService : IBtxAuthenticationService
    {
        public bool Login(string username, string password, bool createPersistentCookie)
        {
            ... irrelevant because this is never hit
        }
    
        public void Logout()
        {
        }
    }
    

    有人能告诉我如何配置这个或者给我指出一种调试它的方法吗。一篇关于用WCF服务实现自定义表单身份验证的文章也将受到欢迎。我尝试过各种其他设置,包括我能找到的所有异常详细信息设置,但没有取得任何进展(尽管我能够进行一些回归,并得到不同的异常,如缺少端点等等)。

    谢谢你抽出时间。

    1 回复  |  直到 14 年前
        1
  •  1
  •   Ladislav Mrnka    14 年前

    不确定这是否有用。我从来没有写过这样的服务,但您的配置创建的WCF服务不是ASP.NETAJAX就绪,可以使用XML而不是JSON。尝试使用此行为而不是webHttp行为:

    <endpointBehaviors> 
      <behavior name="BtxAuthenticationEndpointBehavior"> 
        <enableWebScript /> 
      </behavior> 
    </endpointBehaviors>  
    
    推荐文章