Gravatar ASP.NET Control

Update – 12 June 2008

An updated version of this post, containing full source for the control and explanation is available here.

Original Post

I just got myself a Gravatar over at A Gravatar is a little avatar associated with an email address, and quite a few blogs use them to decorate post comments. Signing up is easy – all you need to do is supply an email address, and image, and give your image a content rating.

The source of the gravatar image tag points to’s image generator and includes an MD5 hash of the email address to prevent email harvesting. A ‘max rating’ parameter prevents the display of unsavoury content.

There are a wide number of blogging gravatar plugins, so I decided to write an ASP.NET custom control to do the job. Here I present the control and its features.

Using the Control

To get up and running, the control requires an email address:

<fcm:Gravatar ID='Gravatar1' runat='server' Email='' />

For my email address, I get the following:

Output for my email address

And if we look at the generated source:

<a id="Gravatar1" href="" title="Get your avatar"><img width="80" height="80" src="" alt="Gravatar" /></a>

The default produces a hyperlink off to the Gravatar site with a title “Get your avatar”. The image contains the MD5 email hash, a rating of “G” (suitable for all audience types), and a size of 80.


The control supports a number of properties supporting the customisation of its output.


The size property of the control can be in the range 1 to 80. If it is outside this range, a default of 80 will be used.


The ‘highest’ allowed rating of image.

  • A G rated gravatar is suitable for display on all websites with any audience type.
  • PG rated gravatars contain may contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence.
  • R rated gravatars may contain such things as harsh profanity, intense violence, nudity, or hard drug use.
  • X rated gravatars may contain hardcore sexual imagery or extremely disturbing violence.


True by default, determines whether a hyperlink linking to the gravatar website will be output around the image.


“Get your avatar” by default, allows the customisation of the ‘title’ attribute of the link (obviously doesn’t apply if OutputGravatarSiteLink property is set to false.)


URL encoded URL, protocol included, of a GIF, JPEG, or PNG image that should be returned if either the requested email address has no associated gravatar, or that gravatar has a rating higher than is allowed by the “MaxAllowedRating” property.

The code snippet below shows the associated properties.

<fcm:Gravatar ID="Gravatar1" runat="server"
    OutputGravatarSiteLink="true" Size="40" />

Download and Get Started

You can download the Gravatar Custom Control here. Once you’ve extracted the assembly from the ZIP file, add to the Visual Studio toolbox by right clicking on the toolbox and selecting “Choose Items” from the context menu. Browse to the assembly (Freshclickmedia.Web.dll), and click “OK” to add.

Adding the control to the toolbox

  • Mark

    Nice work – the customisation is good.

  • Alex

    Thanks for posting this. Is there any chance you can/will release the source for this? I for one would like to play with the implementation. Thanks.

  • shane

    Thanks for the comments guys.

    @Alex: Yes, I’ll be doing another post very soon containing the code, explanation and control.
    Stay tuned.

  • shane

    Hi Alex,

    a follow-up comment to let you know that I’ve posted another Gravatar post containing code explanation, control and demo solution.

    I’d be happy to hear any further comments you have. Check out the new post here.

  • Morten

    Thanks, i will look into this code and maybe use it on my site.

  • Carlo Mendoza

    Easy Peasy

  • Joe

    Testing my Gravatar.

  • saud

    Testing my Gravatar

  • Ryan


  • batchass

    thanks for sharing

  • Andy

    Nice one. That’ll come in handy :)

  • Scott

    Thanks for this. You solved a big problem for me. I really appreciate it.

  • Daniel

    Thanks; Im looking to implement this in one of my current projects.

  • RafaelV

    You and Gravatar are lifesavers! Thank you so much for making this control available.

  • zaladane

    Nice article!

  • GJB


  • Anvil


  • Fabio

    test my gravatar

  • yogesh

    nice one

  • FlashRiver

    Nice work Fresh Media Dudes and Dudettes

  • Compton

    Thank you so much for a very nice control

  • giddyuphorsey


  • Prashant

    test my gravatar

  • Prof


  • Rakesh

    grt work!!!!

  • Vanoin

    nice job

  • Tomas Matejka

    Thanks for a tip!!!

  • Zorn

    good job

  • Henrik Jensen

    Just want to test if it works, i’m a newbee to gravatar

  • jerrey


  • credondo

    Good! Thanks!

  • Alex

    Thanks for sharing!

  • Arturo

    Nice job.


    • Shane

      Apparently, it works well with ASP.NET MVC too. See this comment.

  • Rebwar

    I want to make blog engine and i use it.
    Nice Work

  • Simon

    Nice implementation

  • subbarao

    I am building a blog engine and I will use this , thanks!

  • Vitaliy

    thank you, i try to use that!

  • Divyesh Ardeshana

    nice one..thanks for help

  • KP

    Thanks, this is a great control!

  • Pingback: Avatar universali con Gravatar | Mr.Webmaster – Blog

  • Aleks


  • shamazing

    Sah-weet. Thanks!

  • Pikavippi Vertailu

    Great article and thumbs-up for providing the full source for a C# newbie like me.

  • JaiVinoth

    great work….

  • Glenn

    Thanks. Its great.

  • anil kukadiya

    definately will implement for my blog now

  • parsa

    how should i get or change user’s info?

    • Shane

      Hi parsa,

      You’d most likely use the Email property. Does that help, or do you need more information?

  • hjbavaliya

    gr8 article thanx a lot

  • Baljeet

    Thanksa lot

  • Sreee


  • Jack

    Thanks. I have to test it out right away!

  • roboter

    Thank you! Will be using in my project!

  • sg


  • FIlip Andrei

    Testing, testing..
    Great Work guys!!!

  • Vippi

    Working great!

  • ronibduk

    many thanks

  • simon


  • uuxin


  • Eardley

    Works fine. Thanks!

  • jame


  • Somnath Kadam

    Really great for us

  • Vijay

    Thanks… Good Info….!