• Gravatar HtmlHelper for ASP.Net MVC

    by  • January 8, 2012 • 4 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:

    or

     

    gravatar image examples

    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 :)

    About Andrew Freemantle

    4 Responses to Gravatar HtmlHelper for ASP.Net MVC

    1. July 24, 2012 at 11:56 am

      That was easy! Thank you for the Gravatar code.

      You wouldn’t happen to know how to make it work with their HoverCard using MVC Razor…

    2. July 24, 2012 at 2:09 pm

      Thanks Jules.

      I’ve seen their profiles, but I haven’t found any implementation details to use them as HoverCards – I guess we’d use the profile data feed and make our own..

      Not something I’ve done, but do let me know if you find a project out there that helps, as I’m curious :)

    3. Sebastian
      November 23, 2012 at 8:10 pm

      Thanks for sharing

    4. Raymond
      March 23, 2013 at 12:56 pm

      Great! Thank you for sharing… :-)

    Leave a Reply

    Your email address will not be published.

    Your name *

    Your website

    *