Last Updated: February 25, 2016
·
771
· merys

Render static html with helper

For rendering static html (saved into external file) into mvc view:

public static MvcHtmlString WebPage(this HtmlHelper htmlHelper, string serverPath)
{
    var filePath = HttpContext.Current.Server.MapPath(serverPath);
    return MvcHtmlString.Create(new WebClient().DownloadString(filePath));
}

Calling as is:

@Html.WebPage("~/staticFile.htm")