【发布时间】:2014-02-20 05:43:54
【问题描述】:
在 Umbraco 7.0.3 I 中:
- 使用宏容器的属性编辑器创建了一个名为宏容器的数据类型
- 创建的文档类型称为联系表单,属性称为正文,类型为宏容器
- 创建了名为 _contactForm.cshtml 的局部视图(在 Views\MacroPartials 中)
- 使用 MVC 部分视图 _contactFrom.cshtml 创建了名为 Contact Form 的宏
- 添加了名为“联系我们”的联系表单类型的内容
- 在我的联系我们页面中的宏容器属性中添加了联系表单宏
然后我有一个Surface Controller,我用一些AJAX 调用它来显示页面(更具体地说是页面的Body 属性):
public class JsController : SurfaceController
{
public ActionResult GetPage(int id)
{
var page = new Node(id);
if (page == null || page.GetProperty("body") == null)
return Content(@"Hmm, something went wrong. Unable to find what you're looking for.");
return Content(page.GetProperty("body").Value);
}
}
这个设置几乎可以工作,但问题是返回的不是渲染的表单,而是:
<!--?UMBRACO_MACRO macroAlias="ContactForm" /-->
所以现在我需要渲染这个宏\表单\部分视图...我认为我可能需要在控制器中执行此操作,但如果我可以在另一侧(通过 Javascript)执行此操作,则可以作为好。我可以在控制器中调用 Umbraco 函数来根据页面 id 和宏别名呈现宏吗?
【问题讨论】:
标签: c# ajax asp.net-mvc-4 umbraco7 surface-controller