我想使用我自己的表单将用户添加到 aspnet_Users 表并为他们提供角色。我怎样才能做到这一点?请解释一下。如果您可以提供示例代码,那就太好了。请帮助我的人。提前致谢。
问问题
3032 次
1 回答
2
Great question! The most simple answer is to use the Web Site Administration Tool ASP.Net provides: http://msdn.microsoft.com/en-us/library/yy40ytx0(v=vs.100).aspx
After getting intitial testing out of the way, you undoubtedly will want to do this programmically. You can do this by calling Membership.CreateUser()
as follows:
Membership.CreateUser(
model.UserName,
model.Password,
model.Email,
null,
null,
model.IsApproved,
out createStatus);
Also, the application code provided when building the sample MVCx application provides some great snippets.
于 2012-09-24T14:31:52.060 回答