UrlHelperExtensionsIdenticon Method (UrlHelper, Identicon, Int32, ExportImageFormat)

Generates an URL to an identicon.
public static string Identicon(
	this UrlHelper helper,
	Identicon icon,
	int size = 0,
	ExportImageFormat format = ExportImageFormat.Png
)

Parameters

helperUrlHelper
The UrlHelper.
iconJdenticonIdenticon
The icon that will be rendered.
sizeSystemInt32 (Optional)
The size of the generated icon in pixels. If no size is specified the size of icon will be used.
formatJdenticonExportImageFormat (Optional)
The file format of the generated icon.

Return Value

String

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type UrlHelper. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

ExceptionCondition
ArgumentOutOfRangeExceptionsize was less than 1.
ArgumentNullExceptionhelper or icon was null.

Remarks

This extension method can be used in your cshtml files to generate urls to identicons. Requests to the generated url will be handled by the IdenticonHttpHandler handler, which is automatically installed in your Web.config when installing the Jdenticon.AspNet.Mvc NuGet package.

Examples

This example shows how to use the UrlHelper extension methods to generate identicon urls.

HtmlHelper approach
@using Jdenticon.AspNet.Mvc;

<!-- The following markup -->

<div class="user-info">
    <img src="@Url.Identicon("JohnDoe64", 60)" width="60" height="60" alt="JohnDoe64 icon" >
    <div class="user-info__name">JohnDoe64</div>
</div>

<!-- is rendered as -->

<div class="user-info">
    <img src="/identicon.axd?5AMA8Xyneag78XyneQ--" width="60" height="60" alt="JohnDoe64 icon" />
    <div class="user-info__name">JohnDoe64</div>
</div>

See Also

Reference