使用内置的ASP.NET成员身份来保护Web服务

时间:2009-04-09 21:01:24

标签: web-services asp.net-membership

是否可以使用内置的ASP.NET成员资格提供程序来保护Web服务?

我已经使用我的会员资格设置了一个SQL Server数据库,现在我想提供一个只允许成员使用的Web服务。是否可以对此进行身份验证(如果是这样?)或者我是否需要为Web服务进行单独的身份验证?

2 个答案:

答案 0 :(得分:0)

绝对有可能。您可以将ASP.NET成员资格提供程序与WCF结合使用(去年我将其用于项目)。 (这就是有趣的部分)它只是你需要做的一些配置。 它也适用于ASP.NET RoleProvider的

其他信息:

http://msdn.microsoft.com/en-us/library/ms731049.aspx http://nayyeri.net/blog/use-asp-net-membership-and-role-providers-in-windows-communication-foundation/

答案 1 :(得分:0)

我认为我可以做这样的事情。我现在没有要上传和测试的服务器,但如果有效的话会将其标记为答案:

    [WebMethod]
    public string HelloWorld(String username, String password)
    {
        bool isAuthenticated = Membership.ValidateUser(username, password);

        if (isAuthenticated)
            return "Hello World";
        else
            return "You do not have access to this resource.";
    }
相关问题