matt11 Posted March 13, 2015 Share Posted March 13, 2015 Following ASP.NET tutorial, i have a problem (can't figure out how to) with creating account/logging into a database. database: http://postimg.org/image/6k4ew5kkp/ _AppStart.cshtml: @{ WebSecurity.InitializeDatabaseConnection("SmallBakery", "Product", "Id", "Name", true); } i have added : <appSettings> <add key="enableSimpleMembership" value="true" /> </appSettings> into Web.config Default.cshtml: @{ bool value=WebSecurity.Login("Bread", "parabola", true); } <html> <body> <p>It is @value</p> </body> </html> returns: It is False also some other tables are created i dont know why ?: http://postimg.org/image/g3e3pm82x/ i think it's something password related, bcz UserExists() and GetUserId() work. Link to comment Share on other sites More sharing options...
justsomeguy Posted March 13, 2015 Share Posted March 13, 2015 The username and password need to be set up as a database user and password. It looks like you're trying to store the usernames and password in the database. When you connect to the database you give it a username and password set up on the database server which has permission to access the database. Link to comment Share on other sites More sharing options...
matt11 Posted March 16, 2015 Author Share Posted March 16, 2015 ok, now ... Users database is created and has UserProfile and some other empty tables. _AppStart.cshtml: @{ WebSecurity.InitializeDatabaseConnection("Users", "UserProfile", "UserId", "Email", true); } Default.cshtml: @{ WebSecurity.CreateAccount("tom2", "23456", false); } <html> <body> <p>It is value</p> </body> </html> i get an error on line: WebSecurity.CreateAccount("tom2", "23456", false); Description: An unhandled exception occurred during the execution of the current web request. Exception Details: System.Web.Security.MembershipCreateUserException: The Provider encountered an unknown error. Link to comment Share on other sites More sharing options...
justsomeguy Posted March 16, 2015 Share Posted March 16, 2015 This page shows a few conditions why it might throw that exception:https://msdn.microsoft.com/en-us/library/webmatrix.webdata.websecurity.createaccount(v=vs.111).aspx?cs-save-lang=1&cs-lang=csharpI'm not quite sure what "the database operation failed" would mean, that's not a lot of information to go on. Link to comment Share on other sites More sharing options...
matt11 Posted March 17, 2015 Author Share Posted March 17, 2015 don't know, CreateUserAndAccount works but CreateAccount throws that error. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now