RenderAsHtml() does not use input HttpContextBase

Jan 31, 2012 at 10:23 PM

When I look at the code for RenderAsHtml() when you pass in an HttpContext it is calling the Render method with a null HttpContext.  Is there a reason for this or is it just a bug?

ILSpy output

// RazorGenerator.Testing.WebViewPageExtensions
public static HtmlDocument RenderAsHtml<TModel>(this WebViewPage<TModel> view, HttpContextBase httpContext, TModel model = null)
    string html = view.Render(model);
    HtmlDocument htmlDocument = new HtmlDocument();
    return htmlDocument;

Shouldn't the first line be

string html = view.Render(httpContext, model);

Jan 31, 2012 at 11:18 PM

You may be running an old build. See here for what the current code looks like.