gpt4 book ai didi

asp.net - 在 asp.net 网页中尝试 WebSecurity.CreateAccount 时遇到错误 'The Provider encountered an unknown error'

转载 作者:行者123 更新时间:2023-12-03 03:28:45 26 4
gpt4 key购买 nike

我是 ASP.NET 新手。我正在尝试使用 WebMatrix 创建一个简单的登录和注册网页。但当我尝试创建帐户时出现以下错误:

<小时/>
The Provider encountered an unknown error.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.Security.MembershipCreateUserException: The Provider encountered an unknown error.

Source Error:


Line 32: db.Execute("INSERT INTO UserData (Email,Name) VALUES (@0,@1)", email, username);
Line 33:
Line 34: WebSecurity.CreateAccount(email,password);
Line 35: Response.Redirect("Homepage.cshtml");
Line 36: }


Source File: c:\Users\admin\Documents\My Web Sites\Login\Register.cshtml Line: 34

Stack Trace:


[MembershipCreateUserException: The Provider encountered an unknown error.]
WebMatrix.WebData.SimpleMembershipProvider.CreateAccount(String userName, String password, Boolean requireConfirmationToken) +1312
WebMatrix.WebData.WebSecurity.CreateAccount(String userName, String password, Boolean requireConfirmationToken) +31
ASP._Page_Register_cshtml.Execute() in c:\Users\admin\Documents\My Web Sites\Login\Register.cshtml:34
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +207
System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) +68
System.Web.WebPages.WebPage.ExecutePageHierarchy() +156
System.Web.WebPages.StartPage.RunPage() +19
System.Web.WebPages.StartPage.ExecutePageHierarchy() +65
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76
System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +119

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
<小时/>

感谢任何帮助。谢谢。

最佳答案

我刚刚遇到了同样的问题......我正在使用

WebSecurity.CreateAccount(model.UserName, model.Password);

及以上生成的问题..

然后我尝试了:

WebSecurity.CreateAccountAndUser(model.UserName, model.Password);

并发现我缺少用户表(UserProfile)的其他必填字段。以下对我有用:

WebSecurity.CreateAccountAndUser(model.UserName, model.Password, new {RequiredColumn1 = Value1, RequiredColumn2 = Value 2, ...... });

帖子很旧,但希望这可以帮助其他人..

关于asp.net - 在 asp.net 网页中尝试 WebSecurity.CreateAccount 时遇到错误 'The Provider encountered an unknown error',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14393163/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com