I have been working with ASP.NET MVC4 and needed the ability to generate a random password for a personal website I have been building. The System.Web.Security namespace makes it very easy to accomplish this through one line of code.
string randomPassword = Membership.GeneratePassword(8, 2);
The GeneratePassword method takes in two parameters. The first is the length of the password you wish to generate and the second is the number of non-alphanumeric characters to include in the password. Here is an example of some randomly generated passwords using this method.