Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WCF的表单身份验证_C#_.net_Asp.net Mvc_Wcf_.net 4.5 - Fatal编程技术网

C# WCF的表单身份验证

C# WCF的表单身份验证,c#,.net,asp.net-mvc,wcf,.net-4.5,C#,.net,Asp.net Mvc,Wcf,.net 4.5,如何使用FormsAuthentication概念保护我的简单WCF服务 ServiceContract与此类似: [ServiceContract] public interface MovieDb { [OperationContract] string GetData(int value); [OperationContract] string Login(int value); [

如何使用
FormsAuthentication
概念保护我的简单
WCF
服务

ServiceContract
与此类似:

    [ServiceContract]
    public interface MovieDb
    {
        [OperationContract]
        string GetData(int value);

        [OperationContract]
        string Login(int value);

        [OperationContract]
        string Logout(int value);

    }
我在MVC 4应用程序中使用了
表单身份验证
,用于身份验证和授权

我所能想到的就是在
ServiceContract
类的顶部添加
Authorize
Filter属性


任何简单的指示都非常感谢。谢谢。

我知道MVC中非常有用的Authorize关键字,但到目前为止,我还没有在WCF中找到类似的关键字

如果您正在同一个IIS应用程序中(和)使用WCF服务,则可能需要编写Authorize关键字的自己的实现,但不需要为WCF编写。您可以参考HttpContext来查看请求是否自动调整

可在此处找到一些额外信息:


我知道MVC中非常有用的Authorize关键字,但到目前为止,我在WCF中还没有找到类似的关键字

如果您正在同一个IIS应用程序中(和)使用WCF服务,则可能需要编写Authorize关键字的自己的实现,但不需要为WCF编写。您可以参考HttpContext来查看请求是否自动调整

可在此处找到一些额外信息:


您可以使用用户名/密码保护WCF(表单身份验证):

如果您决定在服务器端的WFC配置中使用成员身份进行身份验证,则会添加配置成员身份的行为:

<behavior name="myBehavior"> 
    <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="myRoleProvider"/>
    <serviceCredentials>
        <serviceCertificate findValue="*.mycert.net" storeLocation="LocalMachine" x509FindType="FindBySubjectName"/>
        <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="myMembershipProvidewr"/>
    </serviceCredentials>
</behavior>
您可以在此处找到其他信息:

您可以使用用户名/密码保护WCF(表单身份验证):

如果您决定在服务器端的WFC配置中使用成员身份进行身份验证,则会添加配置成员身份的行为:

<behavior name="myBehavior"> 
    <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="myRoleProvider"/>
    <serviceCredentials>
        <serviceCertificate findValue="*.mycert.net" storeLocation="LocalMachine" x509FindType="FindBySubjectName"/>
        <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="myMembershipProvidewr"/>
    </serviceCredentials>
</behavior>
您可以在此处找到其他信息: