public static void Image(this HtmlHelper helper, string src, string alt = null, object htmlAttributes = null) { System.Web.UI.HtmlTextWriter writer = new HtmlTextWriter(helper.ViewContext.HttpContext.Response.Output); System.Web.Mvc.TagBuilder tbImage = new TagBuilder("img"); tbImage.MergeAttribute("src", src); tbImage.MergeAttribute("alt", alt); if (htmlAttributes != null) { tbImage.MergeAttributes<string, object>(new RouteValueDictionary(htmlAttributes)); } writer.InnerWriter.Write(tbImage.ToString(TagRenderMode.SelfClosing)); }