C# mvc 如何覆盖render方法

public static class HelperExtensions

{

public static string RenderViewToString(this ControllerContext context, string viewName, object model)

{

if (string.IsNullOrEmpty(viewName))

viewName = context.RouteData.GetRequiredString("action");

context.Controller.ViewData.Model = model;

using (var sw = new StringWriter())

{

ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(context, viewName);

var viewContext = new ViewContext(context,

viewResult.View,

context.Controller.ViewData,

context.Controller.TempData,

sw);

try

{

viewResult.View.Render(viewContext, sw);

}

catch (Exception ex)

{

throw;

}

return sw.GetStringBuilder().ToString();

}

}

}