Force Bundling Optimizations

Use the following code in the BundleConfig.cs of your ASP.NET MVC application to force bundling and minification. // BundleConfig::RegisterBundles BundleTable.EnableOptimizations = true; Why? Why would you do this? Sometimes bundling and minification causes problems, such as in AngularJS. You will want to find these problems before publishing, so just enable this line every once in a while to make sure everything still works as expected with the optimizations.

December 16, 2013

Email Addresses as User Names in ASP.NET Identity

It’s common for web applications to use email addresses instead of user names to distinguish users. However, if you are using ASP.NET Identity, you have probably noticed that it has UserName built into the IUser interface. Since Identity assumes that this is the distinguishing field for the user, it’s not crazy to think that it might be a good place to drop the email address. In order to have Identity allow an email address in this field, you will need to write a custom IIdentityValidator....

November 10, 2013

Email Address in MVC 5 Google Authentication

I’m not proud to admit that I spent hours trying to figure out this very simple problem. The goal was simple: when a user logs into my web application using Google authentication, I want to be able to grab their email address so I can store it as part of their user profile. As expected, this is very simple. I’m assuming you’ve already enabled Google authentication by uncommenting app.UseGoogleAuthentication() in your Startup....

November 9, 2013