asp.net-identity

ASP.Net Identity - Use custom Schema

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 15:44:56
问题 I am using MVC5 + Ef6 code first with ASP.Net Identity 1.0 and wish to have the tables created in a custom schema. i.e. a schema that is not the dbo schema. I reversed engineered my databse using the Ef power tools and set the schema name for all other tables in the mapping class to the following this.ToTable("tableName", "schemaName"); I tried doing this for the ASP.Net tables but it kept giving me a lots of errors and eventually I gave up. If I exclude the (reverse engineered) ASP.Net

Asp.Net Identity 2.0 - How to Implement IIdentityMessageService to do Async SMTP using SmtpClient?

孤街浪徒 提交于 2019-12-17 15:33:15
问题 I've implemented a simple EmailService for Asp.Net Identity 2.0 (via the IIdentityMessageService interface. public class EmailService : IIdentityMessageService { public Task SendAsync(IdentityMessage message) { // convert IdentityMessage to a MailMessage var email = new MailMessage(new MailAddress("noreply@mydomain.com", "(do not reply)"), new MailAddress(message.Destination)) { Subject = message.Subject, Body = message.Body, IsBodyHtml = true }; using (var client = new SmtpClient()) //

Change User Id type to int in ASP.NET Identity in VS2015

雨燕双飞 提交于 2019-12-17 15:25:51
问题 By default ASP.NET Identity in VS 2015 uses a string as a primary key for AspNet*** tables. I wanted to to use int-typed id's instead. After some research it turned out that different typed id's are supported by the framework out of the box. In the answer below I will show what changes to make to achieve that. UPDATE: After adding my answer I found this blog post on asp.net site that describes the same but more comprehensive: http://www.asp.net/identity/overview/extensibility/change-primary

How to inject UserManager & SignInManager

ⅰ亾dé卋堺 提交于 2019-12-17 10:29:13
问题 I am trying to figure out how to inject UserManager and SignInManager. I have installed Ninject in my application and I am using it in the following manner: Please consider this to be a brand new project. Inside Startup.cs I have the following: public partial class Startup { public void Configuration(IAppBuilder app) { ConfigureAuth(app); app.UseNinjectMiddleware(CreateKernel); } private static IKernel CreateKernel() { var kernel = new StandardKernel(); kernel.Load(Assembly

Asp.net Identity Validation Error

纵然是瞬间 提交于 2019-12-17 10:24:18
问题 I want integrate IdentityContext with mydbcontext but i am taking this error One or more validation errors were detected during model generation: Ivdb.Dal.Concrete.EFCodeFirst.IdentityUserLogin: : EntityType 'IdentityUserLogin' has no key defined. Define the key for this EntityType. Ivdb.Dal.Concrete.EFCodeFirst.IdentityUserRole: : EntityType 'IdentityUserRole' has no key defined. Define the key for this EntityType. IdentityUserLogins: EntityType: EntitySet 'IdentityUserLogins' is based on

Creating Roles in Asp.net Identity MVC 5

你离开我真会死。 提交于 2019-12-17 10:10:01
问题 There is very little documentation about using the new Asp.net Identity Security Framework. I have pieced together what I could to try and create a new Role and add a User to it. I tried the following: Add role in ASP.NET Identity which looks like it may have gotten the info from this blog: building a simple to-do application with asp.net identity and associating users with to-does I have added the code to a Database Initializer that is run whenever the model changes. It fails on the

aspnet identity invalid token on confirmation email

南楼画角 提交于 2019-12-17 09:45:09
问题 I'm trying to confirm an account but I'm getting "invalid token." error. Here's what I'm trying: var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmacaoEmail", "Usuario", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(user.Id, "Ativação de Conta", user.GetEmailAtivacao(model.Nome, callbackUrl)); if I call UserManager.ConfirmEmailAsync after this code, I can confirm the account.

Get UserID of logged-in user in Asp.Net MVC 5

别等时光非礼了梦想. 提交于 2019-12-17 09:11:14
问题 I'm relatively new to ASP.Net MVC and try to use the built-in user login functionality now. I'm able to register an user in the registration view. If I try to login with the created user this also works. I'm redirected to the master page. But I'm not able to get the UserID of the current user. I tried my code in the HomeController and in the AccountController, but both didn't work. The statement in the first line returns always null. var userID = User.Identity.GetUserId(); if (!string

Get UserID of logged-in user in Asp.Net MVC 5

假如想象 提交于 2019-12-17 09:11:11
问题 I'm relatively new to ASP.Net MVC and try to use the built-in user login functionality now. I'm able to register an user in the registration view. If I try to login with the created user this also works. I'm redirected to the master page. But I'm not able to get the UserID of the current user. I tried my code in the HomeController and in the AccountController, but both didn't work. The statement in the first line returns always null. var userID = User.Identity.GetUserId(); if (!string

How to implement custom authentication in ASP.NET MVC 5

柔情痞子 提交于 2019-12-17 07:59:20
问题 I'm developing an ASP.NET MVC 5 application. I have an existing DB, from which I created my ADO.NET Entity Data Model. I have a table in that DB which contains "username" and "password" column, and I want to use them to implement authentication and authorization in my Webapp; I cannot create any other database or table or column and I cannot use the standard Identity authentication, because of customer's requirements. I don't need to manage signup, password changing or other stuffs: just