I’ve been using fuslogvw.exe to troubleshoot assembly binding issues for several years so I was pretty surprised to find out that most of the guys on my team had not heard about it. Here’s a link to a great blog post that explains how to use it for those not in the know: http://www.meadow.se/wordpress/viewing-assembly-binding-logs-using-fuslogvw-exe/
Tag: ASP.NET MVC5
Configuring Microsoft.AspNet.Identity in Castle Windsor
It’s very easy to setup Microsoft.AspNet.Identity in the Castle Windsor container if you want to be able to inject UserManager and AuthenticationManager services:
container.Register(Component.For<UserManager>() .UsingFactoryMethod((kernel, creationContext) => new UserManager(new UserStore(new ApplicationDbContext()))) .LifestylePerWebRequest()); container.Register(Component.For() .UsingFactoryMethod((kernel, creationContext) => HttpContext.Current.GetOwinContext().Authentication) .LifestylePerWebRequest());
The assumption here is your application is using a custom user class called ApplicationUser, which is the default setup by the MVC5 template.
There is one slight twist if you want to allow email addresses as user names:
container.Register(Component.For<UserManager>().UsingFactoryMethod((kernel, creationContext) => { var userManager = new UserManager(new UserStore(new ApplicationDbContext())); userManager.UserValidator = new UserValidator(userManager){AllowOnlyAlphanumericUserNames = false}; return userManager; }).LifestylePerWebRequest()); container.Register(Component.For() .UsingFactoryMethod((kernel, creationContext) => HttpContext.Current.GetOwinContext().Authentication) .LifestylePerWebRequest());