Gravatar HtmlHelper for ASP.Net MVC

0 Comments
Update: This implementation is now linked from the official Gravatar website!

Inspired by a recent project at work, here’s a complete implementation of the Gravatar image request API, as an ASP.Net MVC 3 / MCV4 HtmlHelper.

It includes the help and documentation from the Gravatar API page, and automatically does HTTPS/SSL requests if included on a page that is served securely (secure requests can be forced too).

Getting Started

  1. Head over to the project page on GitHub, and save the single file GravatarHtmlHelper.cs into your project
  2. Start using it with the HtmlHelper sytax, like so:
@Html.GravatarImage("[email protected]")

or

@Html.GravatarImage(  
  "[email protected]",  
  32,  
  GravatarHtmlHelper.DefaultImage.Identicon,  
  false,  
  GravatarHtmlHelper.Rating.G)  

Gravatars

and that’s it! The helper method is progressively overloaded, so you need only supply the minimum parameters to get the Gravatar you’re after.

Comments and suggestions are welcome here or on the projects issue tracker over at GitHub. I hope you find it useful