private string ConvertViewToHtmlString(ControllerContext c, string viewName, object data)
{
if (data != null)
{
//set view data notifications
ViewData.Model = data;
StringWriter output = new StringWriter();
//find the view to general html string
ViewEngineResult result = ViewEngines.Engines.FindView(c, viewName, "");
ViewContext viewContext = new ViewContext(c, result.View, ViewData, TempData, output);
try
{
//render the view to stringWriter, rather than on Response stream
result.View.Render(viewContext, output);
}
finally
{
//release the view so that it can be used by other controllers
result.ViewEngine.ReleaseView(c, result.View);
}
//html string for the view
return output.ToString();
}
else
{
return "";
}
}
经过上面的方法以后变成了如下啊
<div style="margin-left:8px; margin-right:8px">
<img src="http://localhost:16711https://join.expediapartnercentral.com.lisqa8.sb.karmalab.net/onboarding///photos/displayphotoforemail?photoid=4133&hotelid=8014091"
style="width:80px; height:80px;margin-top:2px;" alt=해야 합니다..JPG />
</div>