asp.net-mvc-5

How to Extend Microsoft.AspNet.Identity.EntityFramework.IdentityRole

雨燕双飞 提交于 2019-11-30 16:29:04
I want to be able to extend the default implementation of IdentityRole to include fields like Description. It's easy enough to do this for IdentityUser because IdentityDbContext takes a generic parameter of type IdentityUser. However, IdentityDbContext doesn't allow you to do this for IdentityRole. How can I accomplish this? I know I can create a basic DbContext, and implement my own IUserStore, so that I can use my own role class, but I really don't want to have to do that. Any thoughts? I have just gone through this pain myself. It actually turned out to be pretty simple. Just extend

ASP.NET MVC 5 renders different bool value for hidden input

老子叫甜甜 提交于 2019-11-30 16:23:26
问题 Given the following viewmodel: public class FooViewModel { public bool IsBoolValue { get; set; } } and this view: <input type="hidden" id="Whatever" data-something="@Model.IsBoolValue" value="@Model.IsBoolValue" /> The output of the hidden input field is this: <input type="hidden" id="Whatever" data-something="True" value="value"> How come the value attribute is not set to True , but the data-something attribute is? Is there a change in MVC 5 that would cause this, since in my MVC 4 apps this

UserId not found error in aspnet Identity at GenerateUserIdentityAsync method

自作多情 提交于 2019-11-30 16:16:32
问题 I am getting UserId not found error after registring a user and also after login.Moreoever, after registration, data is saved to database and in dbo.AspNetUsers table, id column is auto incremented and return type is int. There is UserId Column in AspNetUserClaims table.It has 4 Col---Id,UserId,ClaimType,ClaimValue.It has Id column as auto incremented not the userId. I was initially successfully changed Primary key from string to int by following this link---http://www.asp.net/identity

UserId not found error in aspnet Identity at GenerateUserIdentityAsync method

会有一股神秘感。 提交于 2019-11-30 15:59:24
I am getting UserId not found error after registring a user and also after login.Moreoever, after registration, data is saved to database and in dbo.AspNetUsers table, id column is auto incremented and return type is int. There is UserId Column in AspNetUserClaims table.It has 4 Col---Id,UserId,ClaimType,ClaimValue.It has Id column as auto incremented not the userId. I was initially successfully changed Primary key from string to int by following this link--- http://www.asp.net/identity/overview/extensibility/change-primary-key-for-users-in-aspnet-identity . It was running succesfully before

UserManager.Create(user, password) thowing EntityValidationError saying Id is required?

你离开我真会死。 提交于 2019-11-30 15:46:57
问题 Anybody know why UserManager.Create(user, password); might be throwing EntityValidationError saying Id is required. Could it have something to do with my UserManager . It is setup like this: public class MyAppDb : IdentityDbContext<ApplicationUser, ApplicationRole, string, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim> { public static MyAppDb Create() { return new MyAppDb(); } public MyAppDb() : base("MyAppDb") { } } public class ApplicationUserStore : UserStore

UserManager.Create(user, password) thowing EntityValidationError saying Id is required?

人盡茶涼 提交于 2019-11-30 14:42:56
Anybody know why UserManager.Create(user, password); might be throwing EntityValidationError saying Id is required. Could it have something to do with my UserManager . It is setup like this: public class MyAppDb : IdentityDbContext<ApplicationUser, ApplicationRole, string, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim> { public static MyAppDb Create() { return new MyAppDb(); } public MyAppDb() : base("MyAppDb") { } } public class ApplicationUserStore : UserStore<ApplicationUser, ApplicationRole, string, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim> { public

Multiple RoutePrefixes per controller using MVC Attribute routing?

匆匆过客 提交于 2019-11-30 14:41:37
With the new MVC Attribute routing, I know you can assign multiple Route attributes to a single ActionResult , but I am looking for a way to do the same at the RoutePrefix level. I have a controller which, in every action, should be accessible by three routes: /Games/{Title}/Characters/{Route} /Books/{Title}/Characters/{Route} /Cinema/{Title}/Characters/{Route} I tried putting three individual RoutePrefix attributes, but I get the error Deuplace RoutePrefix attribute . If I try to use a comma-separated list, I get Best override method for does not contain a constructor that takes 3 arguments .

MVC5 Account Controller null reference exception

落爺英雄遲暮 提交于 2019-11-30 14:03:13
问题 I am trying to implement user roles into my MVC web application. However I am getting a null exception on the line return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>(); in my account controller. Account Controller [Authorize] public class AccountController : Controller { private ApplicationSignInManager _signInManager; private ApplicationUserManager _userManager; private ApplicationRoleManager _roleManager; public AccountController(){} public

How to logout user in OWIN ASP.NET MVC5

只谈情不闲聊 提交于 2019-11-30 13:57:49
问题 I have got a standard AccountController class of ASP.NET MVC5 project. When I try to log out user I am facing an error coz HttpContext is null . (I mean here HttpContext .GetOwinContext().Authentication is null) So I cannot get how we can logout user when session ends... In global.asax I have got this protected void Session_Start(object sender, EventArgs e) { Session.Timeout = 3; } protected void Session_End(object sender, EventArgs e) { try { var accountController = new AccountController();

How can I get angular2 to work in Visual Studio 2015 with TypeScript?

三世轮回 提交于 2019-11-30 13:45:40
问题 I am trying to get Angular 2 to work in Visual Studio 2015 with Typescript . I am trying to get the most basic example to work in an MVC 5 type web project ( web.config instead of config.json ): import {Component, bootstrap} from 'angular2/angular2'; @Component({ selector: 'my-app', template: '<h1>My First Angular 2 App</h1>' }) class AppComponent { } bootstrap(AppComponent); I'm trying the most minimal things needed to make this work. So I downloaded the most recent Angular 2 (alpha .45) and