免责声明:我编辑了问题,因为我更改了过程,但这并不改变问题的任何内容...
我正在尝试将PartialViewResult渲染为字符串,我尝试使用这个问题的RenderRazorViewToString方法render a view as a string...,我从这个问题中得到了提示mvc return partial view as json 我的问题是,该字符串看起来像这样:
代替这个
更新:
流程看起来像这样:
我正在尝试将PartialViewResult渲染为字符串,我尝试使用这个问题的RenderRazorViewToString方法render a view as a string...,我从这个问题中得到了提示mvc return partial view as json 我的问题是,该字符串看起来像这样:
<$A$><h1>SomeHeader</h1>
<table</$A$><$B$> class="table table-striped"</$B$><$C$>> <tbody</$C$><$D$> data-bind="template: { name: 'eventTemplate', foreach: events }"</$D$><$E$>></tbody>
</table></$E$>
代替这个
<h1>SomeHeader</h1>
<table class="table table-striped">
<tbody data-bind="template: { name: 'eventTemplate', foreach: events }"></tbody>
</table>
更新:
流程看起来像这样:
public ActionResult Index(string item, long id)
{
var cont = SomePartialView(item, id);
return View(model: RenderRazorViewToString(cont));
}
现在,View只是像这样呈现字符串:
@Model
RenderRazorViewToString(PartialViewResult)
返回这个“残缺”的字符串...