Gravatar Code Location?

Topics: ASP.NET 2.0, Controls, Themes
May 4, 2011 at 9:21 PM

Hi all. I've been looking for weeks for the location of the code in 2.0 that creates the Gravatar code. I want to manipulate it so that I can create custom avatars on a blog that aren't as goofy as the default monsterids/wavatars/indenticon that come included with BlogEngine.

The closest I've come to finding any code that references gravatar is in here: admin>pages>RecaptchaLogViewer.aspx

Unfortunately I have found that this code isn't what is being used on the comment gravatars. I've commented out lines and lines of code on this page and the comments avatars aren't affected in the least.

Does anyone have any idea where this code is? I feel like I've looked everywhere so any help would be very much appreciated.


May 5, 2011 at 3:47 AM
Edited Oct 24, 2011 at 6:59 PM

The Gravatars is a service:


Not BlogEngine, Blogengine is just using it but not actually providing the images.  Images comes from Gravatar which is random, but can be changed if you or your users sign up through Gravatar and uploaded

their own image for their Gravator.


Look at mine

So now when I post on any website that supports Gravator my image will be show for my user.


Your Gravatar is an image that follows you from site to site appearing beside your name when you do things like comment or post on a blog. Avatars help identify your posts on blogs and web forums,


The file you are looking for is in the source: BusinessLogic/Avatar.cs



Java Blog

May 5, 2011 at 8:08 AM

As an alternative to using the goofy default avatars, it seems you can use a single default image instead.

This might not be quite what you want, but it is an option, although it does require altering code out-with the theme.

May 5, 2011 at 7:42 PM

Thanks for your response.

This seems like a good option actually, in fact I've come across this article before and tried to implement this as a solution.

The problem is I'm using BlogEngine2.0 and this code just doesn't seem to exist in the new version. That's what's frustrating me so much. The only place I see where BE could be calling gravatar in the whole site is in this RecaptchaLogViewer.aspx.cs file. But if I delete this file (RecaptchaLogViewer.aspx.cs) from the site the gravatar functioning still works fine as if nothing happened...

May 5, 2011 at 8:04 PM

Thanks for your response. I actually do understand that Gravatar and BE are separate entities and that BE is only using the Gravatar service.

The problem is I can't find in the BE code where BE is calling the Gravatar service. I want to be able to try and manually alter this code so that users that do not have Gravatar images have a different, custom image, by their username.

May 5, 2011 at 8:43 PM
Edited May 5, 2011 at 8:49 PM

Have a look at the file Avatar.cs that KB pointed to, looks like the logic you require has been moved there.

This code below is taken from Avatar.cs, compare this to the code in the article that referenced the BlogEngine.Core.Web.CommentViewBase.cs file.


 var gravatar = string.Format("{0}.jpg?s={1}&d=", hash, size);

            string link;
            switch (BlogSettings.Instance.Avatar)
                case "identicon":
                    link = string.Format("{0}identicon", gravatar);

                case "wavatar":
                    link = string.Format("{0}wavatar", gravatar);

                    link = string.Format("{0}monsterid", gravatar);

            imageTag = string.Format(
                CultureInfo.InvariantCulture, AvatarImage, link, HttpUtility.HtmlEncode(description));

            return new Avatar { Url = new Uri(link), ImageTag = imageTag };
Aug 26, 2011 at 3:33 PM

Where would the BlogEngine.Core.Web.CommentViewBase.cs be found? I have looked and looked and can't find it.


Aug 26, 2011 at 4:33 PM

Depending on what you want to do there is a CommentViewBase.cs file in the User controls folder in the BE root directory or if you have the BE source files (which is more likely what you are looking for) you can look under BlogEngine\BlogEngine.Core\Web\Controls\

Aug 27, 2011 at 4:56 PM

Thanks for the quick reply! I did find the CommentViewBase.cs file in the User controls folder and that did not help me out. I am sorry I am such a moron but I still can't find the BlogEngine\BlogEngine.Core\Web\Controls\ folder... I have no folder called BlogEngine, BlogEngine.Core, or web that I can find.

I have a GoDaddy account and they set it up for me (I wish I would have done it myself but ohh well). When looking at my root directory I see the following directories:

Admin, API, App_GlobalResources, App_Data, App_Code, bin, editors, pics, setup, themes, user controls, widgets.

I am a little confused.... any help?


Aug 27, 2011 at 8:39 PM

You will need the source code version of BE to get the file you are looking for, which should contain 3 main sub folders: BlogEngine.Net, BlogEngine.Modeling and BlogEngine.Core (or DotNetSlave.BusinessLogic in the most recent versions of BE).

Normally it's only the contents of the BlogEngine.Net folder that end up on the server, which explains why you would not be able to find the file.

Your best bet might be to go to the 'Source Code' section at the top of this forum and find the version that matches your version of BE and download it to a suitable location on your local machine.

Once downloaded and unzipped, look in either BlogEngine.Core\Web\Controls\ or DotNetSlave.BusinessLogic\Web\Controls\ for the required file.

Microsoft Visual Web Developer is free to download, you could use this to open the project file (of type Microsoft Visual Studio Solution) and play around with the code offline (all relevant code should be visible from the Solution Explorer in Visual Web Developer).

When you are happy with the changes and assuming the builds go well, then if memory serves me correctly you will need to swap the Bin folder on the server with the Bin folder from your offline BlogEngine.Net folder.

Hope this makes some sort of sense... don't forget to backup the current install.