simplemembership

MVC 4 SimpleMembership - Why WebSecurity.CurrentUserId -1 after login

情到浓时终转凉″ 提交于 2019-12-28 04:26:16
问题 I am trying to set a cookie upon login and having issues with getting the current user id after login. In the below, intUserId is -1 and WebSecurity.IsAuthenticated is false. Is this not the correct place to put this code? After this, it redirects to the home page...so not sure why this is not the correct place. // POST: /Account/Login [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid && WebSecurity

ASP.NET MVC 4 C# - Internet Application Template using default SimpleMembership, Error: System.Data.SqlClient.SqlException: Login failed for user xxx

放肆的年华 提交于 2019-12-25 03:54:28
问题 I am running the application locally (localhost), and since I have already registered, I log in properly and then can navigate regularly through all the pages of my application. Then without logging out, I close the IIS express. But when I start again the IIS Express and debug again my application from Visual Studio, the following Error is displayed in my browser: " Server Error in '/' Application. Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'xxx'.". Where

Error using AddUserToRole of SimpleMembership: INSERT statement conflicted with the FOREIGN KEY constraint

怎甘沉沦 提交于 2019-12-25 02:42:48
问题 I'm using asp.net mvc4, c# and Entity Framework 5. I am trying to create a user and assign role to the user at the same time using simple membership (database first approach), but getting the following error at Roles.AddUserToRole("nuser", "Admin"); The INSERT statement conflicted with the FOREIGN KEY constraint "FK_webpages_UsersInRoles_webpages_Roles". The conflict occurred in database "DbClick2Eat", table "dbo.webpages_Roles", column 'RoleId'. The statement has been terminated. Here is my

Timeout option for Simplemembership

a 夏天 提交于 2019-12-24 15:48:02
问题 Does simplemembership have an easy way to set a timeout to automatically log you out after a certain amount of time has passed while you've been inactive? 回答1: SimpleMembership doesn't provide a timeout you can configure, the authentication mechanism does. If you are using FormsAuthentication, you can setup this timeout here: <authentication mode="Forms"> <forms loginUrl="~/Login" timeout="20" slidingExpiration="true" /> </authentication> In the example above the timeout is set to 20 minutes.

Move simple membership profider functionality to class library project

与世无争的帅哥 提交于 2019-12-24 13:48:09
问题 I'm trying to move my DbSet 's to a class library project that is going to be used for database operations. I've been following this tutorial to a Code First / SimpleMembershipProfider project. I've already got the database filled with new tables etc, via the class lib project. But i am missing the webpages_ tables you can see on this image. This is my datacontext class: public class DataContext : DbContext { public DataContext() : base("DefaultConnection") { } public DbSet<Orders> Orders {

PostgreSQL + Npgsql connector + MVC and SimpleMembership Not working

ぐ巨炮叔叔 提交于 2019-12-24 08:55:32
问题 I've test the db connection without Websecurity and it works. I've followed the tutorial from Brice Lambson http://brice-lambson.blogspot.com.es/2012/10/entity-framework-on-postgresql.html But when I use WebSecurity.InitializeDatabaseConnection("myContext", "UserProfile", "UserId", "UserName", autoCreateTables: false); I get this exception: System.InvalidOperationException was caught HResult=-2146233079 Message=No user table found that has the name "UserProfile". Source=WebMatrix.WebData

PostgreSQL + Npgsql connector + MVC and SimpleMembership Not working

五迷三道 提交于 2019-12-24 08:52:21
问题 I've test the db connection without Websecurity and it works. I've followed the tutorial from Brice Lambson http://brice-lambson.blogspot.com.es/2012/10/entity-framework-on-postgresql.html But when I use WebSecurity.InitializeDatabaseConnection("myContext", "UserProfile", "UserId", "UserName", autoCreateTables: false); I get this exception: System.InvalidOperationException was caught HResult=-2146233079 Message=No user table found that has the name "UserProfile". Source=WebMatrix.WebData

SimpleMembershipProvider in MVC4 throws NotSupportedException on methods when initialized

a 夏天 提交于 2019-12-24 03:27:43
问题 I am using the built-in SimpleMembership of the ASP.net MVC4 template and want to create an admin panel to reset passwords and similar operations on the user base. I am using SecurityGuard.MVC4 nuget as starting point and am getting NotSupportedException on most actions. SecurityGuard uses the Membership property of the controller to call methods such as GetAllUsers(), GetUser() and ResetPassword() on SimpleMembershipProvider and they all throw NotSupportedException. From documentation it

WebSecurity.Logout() then WebSecurity.IsAuthenticated returns true

不问归期 提交于 2019-12-24 00:46:09
问题 Consider that the user has a valid auth cookie, but their account has been deleted (from a different location) WebSecurity.IsAuthenticated returns true. WebSecurity.CurrentUserName returns the user's username, despite their account being deleted. Presumably, this info is encrypted in the auth cookie. As it turns out, IsAuthenticated gets its answer from the current HttpContext's request: this._context.User.Identity.IsAuthenticated So, to mitigate: var userName = WebSecurity.CurrentUserName;

Buddy ViewModel with LINQ Join

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 05:13:06
问题 SOS! What I am trying to achieve is for the logged in person, to see the users he or she is supporting (buddying). I am now trying to fully embrace ViewModels to coagulate views. I am using simplemembership MVC4 with Mysql. I have a UserProperties(all details of my users)linked to Userprofile and Everything else works. I usually use two databases one for membership and another for all other stuff. models UserProfile/UserProPerties - extended for all other properties UserId List item UserName