HtmlHelperExtensions | HtmlHelper extension methods for Jdenticon.
| |
IdenticonHttpHandler | IHttpHandler implementation used to serve icons.
| |
IdenticonResult |
Defines a result that will render and return an identicon.
| |
UrlHelperExtensions | UrlHelper extension methods for Jdenticon.
|
To use Jdenticon from ASP.NET MVC, install the Jdenticon.AspNet.Mvc NuGet package.
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.
@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.
<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.
public class IconController : Controller { public ActionResult Icon(string value, int size) { return IdenticonResult.FromValue(value, size); } }