We are developing an application where one of our MVC views is simply to render HTML snippets from an external file. Since our favorite internet search engine did not turn up any information on how to do this, I am posting the following information.
You can quickly read in the entire file to a string as follows:
public static string GetHTMLContents(string filename)
string results = string.Empty;
results = File.ReadAllText(filename);
ViewData["HTMLContent"] = results;
and in the View render it with code that looks like:
<span style=" text-decoration:underline">HTML Content:</span><br/>
<%= ViewData["HTMLContent"] %>
Hope that helps.
Okemos, MI USA
January 16, 2010