Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encountering error 'The Provider encountered an unknown error' while trying WebSecurity.CreateAccount in asp.net webpage

I am new to asp.net. I am trying to create a simple login and register webpage with WebMatrix. But I get the following error when I try to create an account:


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

Any help is appreciated. Thanks.

like image 423
shruthi Avatar asked Jan 18 '13 05:01

shruthi


1 Answers

I just had the same issue ... I was using

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

and above generated issue ..

then I tried:

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

and find out that I was missing other required fields of my Users table (UserProfile). Following worked for me:

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

The post is old, but hope this can help others..

like image 169
NMathur Avatar answered Oct 02 '22 10:10

NMathur