简体   繁体   中英

ASP.NET Web Service and Membership

I try use Membership in asmx web service. I use Web Site Administration Tool, create som roles and users.

In asmx web service I create Login method a test some users account. It's work ok.

[WebMethod]
public string Login(string userName, string userPassword)
{
    if(Membership.ValidateUser(userName,userPassword))
    {
        return "Login succesfull";
    }
    return "Bad loginName or password";
}

The I add method on create user account.

    [WebMethod]
    public void CreateUser(string userName, string userPassword, 
        string userEmail, string userQuestion, string userAnswer)
    {
        MembershipCreateStatus status;
        try
        {
            Membership.CreateUser(userName, userPassword,
                        userEmail, userQuestion, userAnswer, true, out status);
        }
        catch (MembershipCreateUserException ex)
        {
            throw ex;
        }
        catch(Exception ex)
        {
            throw ex;
        }

    }

Problem is, if I call webmethod CreateUser user account is not created. The user data are not written into database. I don't get any exception when I call webmethod CreateUser, where can be problem? Anybody help me? Thank you.

默认情况下,您必须跟进强大的密码输入,必须使用大写字母数字和特殊字符,即使用“ PassW @ rd22”,谢谢哈米德。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM