ASP.NET Web Pages Using The Razor Syntax
Chapter 13 – Adding Social Networking to Your Web Site
code statement, replace
<Insert search criteria here>
with the text
you want to search for.
Run the page in a browser.
Rendering a Gravatar Image
A Gravatar (a "globally recognized avatar") is an image that can be used on multiple websites as your
avatar — that is, an image that represents you. For example, a Gravatar can identify a person in a forum
post, in a blog comment, and so on. (You can register your own Gravatar at the Gravatar website at
http://www.gravatar.com/.) If you want to display images next to people's names or email addresses on
your website, you can use the Gravatar helper.
In this example, you're using a single Gravatar that represents yourself. Another way to use Gravatars is
to let people specify their Gravatar address when they register on your site. (You can learn how to let
people register in Chapter 16 – Adding Security and Membership.) Then whenever you display
information for that user, you can just add the Gravatar to where you display the user's name.
Add the ASP.NET Web Helpers Library to your website as described in Chapter 1, if you haven't
Create a new web page named Gravatar.cshtml.
Add the following markup to the file:
@Gravatar.GetHtml("<Your Gravatar account here>")
@Gravatar.GetHtml("<Your Gravatar account here>", 40)
method displays the Gravatar image on the page. To change the size of
the image, you can include a number as a second parameter. The default size is 80. Numbers
less than 80 make the image smaller. Numbers greater than 80 make the image larger.
<Your Gravatar account here>
with the email
address that you use for your Gravatar account. (If you don't have a Gravatar account, you can
use the email address of someone who does.)
Run the page in your browser. The page displays two Gravatar images for the email address you
specified. The second image is smaller than the first.