simplemembership

Simple Membership Provider - Entity Framework and Roles

你说的曾经没有我的故事 提交于 2019-12-04 09:14:45
I'm attempting to use the Simple Membership Provider with MVC 4 as "by the book" as possible. Here is the current scenario: -- I've been using Jon Galloway's blog post on the topic here . 1) I'm aware this thing is wired via Entity Framework. I did notice, however, that when I added properties to the UserProfile class, they didn't appear in the table automatically when it was generated. Is this due to the database already being generated (tables were not present)? I manually added the fields and it was functional, but would be nice to know the "gotchas" that would result in the fields not

Get logged in user's id

孤者浪人 提交于 2019-12-04 09:02:36
问题 How can I get the logged in user's UserId? I'm using the standard system generated AccountModel. I can get the username using: User.Identity.Name but I don't see the UserId field. I want to use the UserId as a foreign key for another table. 回答1: I think you're looking for ProviderUserKey - Gets the user identifier from the membership data source for the user. object id = Membership.GetUser().ProviderUserKey Membership.GetUser() - Gets the information from the data source and updates the last

How to create simple membership sql tables manually?

我与影子孤独终老i 提交于 2019-12-04 05:09:04
I'm looking for a tool similar to Aspnet_regsql.exe for ASP .NET Membership just for simpleMemberShip Provider. Creating the tables at runtime is too late, cause a client program uses the same tables. UserProfile webpages_Membership webpages_OAuthMembership webpages_Roles webpages_UsersInRoles Any advice would be great You could just create the script yourself, using SQL Management Studio, after running your application on your developer machine: Example follows from a similar task I did (note dates, not sure if anything has changed). Note: you'll need to create the database and do the normal

Seeding data and creating/managing roles in MVC4 - how hard can it be?

对着背影说爱祢 提交于 2019-12-04 01:57:42
问题 I'm about to go insane, so I'll try getting some help one more time... I'm using Visual Studio Express 2012 for Web to create an internet project using C# + MVC4 + Razor + Entity Framework + ASP.NET 4.5. I need to do the following: automatically create an "admin" user (who will be authorized all over the site) and then create some user roles. I've read about SimpleMembership, roles and everything all over the web, but nothing seems to give me a straightforward method to make the whole thing

code first membership provider

你离开我真会死。 提交于 2019-12-03 22:01:39
How can I integrate EF 5.0 with membership provider using code first? I have my own database schema which I want to use for registration of users etc. You should take a look at the SimpleMembershipProvider It is very easy to use it together with EF. Update For MVC4 I would start with the blank template. you need WebSecurity.InitializeDatabaseConnection to set up the database. WebSecurity.InitializeDatabaseConnection("DefaultConnection", "Users", "Id", "UserName", true); It takes as parameters a name of a connectionstring, the table, a unique identifier column and the username-column. The model

MVC 4 authentication with Active Directory or Membership database

我只是一个虾纸丫 提交于 2019-12-03 14:24:29
I´m building a web application which could get accessed in two ways. Everyone who is working in the same organisation as I can use our active directory to access the application. Everyone from outside should join the application through a separate membership database. Everyone should have a account in the membership database with his roles, so the ad connection is just a bonus to make it easier to keep the password and username in mind. I searched the internet but couldn't find a comparable situation. This is my first time working with ad. Does anyone know of a framework that can be used or

Editing user profile details

荒凉一梦 提交于 2019-12-03 10:16:13
How to create action and views for editing user custom informations? Authorization is based on membership created by VS with MVC 4 project. I've added additional columns, such as FirstName etc. I needed and registration works correctly, but I don't know how to get this attributes to show in view for @Html.EditorFor and to save changes in database (table UserProfile). Many thanks for every tip. Created model for edition: public class UserProfileEdit { [Required] [Display(Name = "First name")] public string FirstName { get; set; } [Required] [Display(Name = "Last name")] public string LastName {

Get logged in user's id

蓝咒 提交于 2019-12-03 01:43:54
How can I get the logged in user's UserId? I'm using the standard system generated AccountModel. I can get the username using: User.Identity.Name but I don't see the UserId field. I want to use the UserId as a foreign key for another table. I think you're looking for ProviderUserKey - Gets the user identifier from the membership data source for the user. object id = Membership.GetUser().ProviderUserKey Membership.GetUser() - Gets the information from the data source and updates the last-activity date/time stamp for the current logged-on membership user. Try this: using Microsoft.AspNet

ASP.NET simple membership provider?

允我心安 提交于 2019-12-03 00:44:54
I opened Asp.Net Mvc 4 Internet App. template. And I set connection string for my database like this: <connectionStrings> <add name="DefaultConnection" connectionString="Data Source=ALI-PC\;Initial Catalog=OsosPlusDb;Persist Security Info=True;User ID=sa;Password=sa;" providerName="System.Data.SqlClient" /> </connectionStrings> I run project, click register button. I created a new user like this: When I click register to post I get this error: But it creates a new user in DB and it does not create membership_user (Membership table is not contain added user info): I cant find What is the

SimpleMemership CreateUserAndAccount Customization

怎甘沉沦 提交于 2019-12-02 22:25:14
I am trying to add a new property to the UserProfile class in my model public class UserProfile { [Key] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public int UserId { get; set; } public string UserName { get; set; } [Required] [DataType(DataType.EmailAddress)] [Display(Name = "Email Address")] public string Email { get; set; } \\this is the new property public virtual IList<Game> Games { get; set; } } I am trying to add it to my seed method in my Configurations.cs file private void SeedMembership() { WebSecurity.InitializeDatabaseConnection("MafiaContext", "UserProfile",