Jdenticon.AspNet.Mvc Namespace

Classes for using Jdenticon from ASP.NET MVC.


Public classHtmlHelperExtensions
HtmlHelper extension methods for Jdenticon.
Public classIdenticonHttpHandler
IHttpHandler implementation used to serve icons.
Public classIdenticonResult
Defines a result that will render and return an identicon.
Public classUrlHelperExtensions
UrlHelper extension methods for Jdenticon.


To use Jdenticon from ASP.NET MVC, install the Jdenticon.AspNet.Mvc NuGet package.

NuGet Package Manager
PM> Install-Package Jdenticon.AspNet.Mvc

Jdenticon can be used in multiple ways in ASP.NET MVC. The first example shows how to use the HtmlHelper extension methods to render an IMG element on the page.

HtmlHelper approach
@Html.Identicon("TestIcon", 60, alt: "Identicon")

is rendered as:
<img src="/identicon.axd?5AMA8Xyneag78XyneQ--" width="60" height="60" alt="Identicon" />

The following example shows how to use the UrlHelper extension methods for generating identicon urls.

UrlHelper approach
<img src="@Url.Identicon("TestIcon", 60)" alt="Identicon" width="60" height="60" >

is rendered as:
<img src="/identicon.axd?5AMA8Xyneag78XyneQ--" alt="Identicon" width="60" height="60" >

It is also possible to return an identicon as a result from a ASP.NET MVC controller. Note that the actual icon data is returned by the IdenticonResult. The other two approaches utilize urls handled by the IdenticonHttpHandler.

Identicon as action result
public class IconController : Controller
    public ActionResult Icon(string value, int size)
        return IdenticonResult.FromValue(value, size);