首先,我要确认我可以在c#windows form app中使用会员表吗?因为当我使用它时,它会在下一行中给出错误
MembershipCreateStatus mcs = new MembershipCreateStatus();
MembershipUser user = Membership.GetUser(txtusername.Text, false);
if (user != null)
{
Msg.Text = "The user name " + Server.HtmlEncode(txtusername.Text) + " already exist. Please Choose another";
return;
}
MembershipUser users = Membership.CreateUser(txtusername.Text, txtpassword.Text, txtusername.Text, "Who am i?", "Patient", true, out mcs);
它说“名称服务器在当前上下文中不存在”。其次,当我省略这部分并编写以下代码时
Msg.Text = "The user name " + txtusername.Text + " already exist. Please Choose another";
答案 0 :(得分:1)
实际上,您无法在Windows窗体应用程序中使用System.Web中的Membership类。原因是Membership与ASP.NET管道密切相关,并且打算在Web应用程序中使用。查看其他技术来保护您的应用。例如,请查看PrincipalPermissionAttribute