在Umbraco 7.0.3中我:
然后我有一个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);
}
}
Run Code Online (Sandbox Code Playgroud)
这个设置几乎可以工作,但问题是,而不是渲染的表单,返回的是:
<!--?UMBRACO_MACRO macroAlias="ContactForm" /-->
Run Code Online (Sandbox Code Playgroud)
所以现在我需要渲染这个宏\ form\partial视图...我认为我可能需要在Controller中执行它,但是如果我可以在另一端(通过Javascript)这样做也可以.是否有一个Umbraco函数我可以在控制器中调用基于页面ID和宏别名渲染宏?
我基本上有一个联系表单,我需要POST到我的Umbraco后端.前端看起来类似于:
using (Html.BeginUmbracoForm("HandleFormSubmit", "ContactForm", FormMethod.Post)) {
<form>
<input name="Name" type="text" />
<button type="submit">Send</button>
</form>
}
Run Code Online (Sandbox Code Playgroud)
然后我有一个表面控制器/Controllers/ContactFormController.cs,看起来像:
public class ContactFormController : SurfaceController {
// GET: ContactForm
public ActionResult Index() {
return PartialView("ContactForm", new ContactForm());
}
[HttpPost]
public ActionResult HandleFormSubmit(ContactForm model) {
return RedirectToCurrentUmbracoPage();
}
}
Run Code Online (Sandbox Code Playgroud)
我想尝试HandleFormSubmitPOST方法.GET方法有效(断点证明了这一点).无论我做什么,我都无法接受这种方法.我看过很多指南,所有这些指南似乎与此完全相同.
POST数据如下:
url: /contact-us/
data: name="Test"
Content-Type: multipart/form-data
Run Code Online (Sandbox Code Playgroud)
我在这做错了什么?使用Umbraco 7.6.6