Sitecore MVC表单回发不返回完整布局 [英] Sitecore MVC form postback does not return a full layout

查看:72
本文介绍了Sitecore MVC表单回发不返回完整布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用已启用MVC的Sitecore 7.我有一个cshtml布局,其中包含页眉,菜单,页脚和占位符.

i'm using Sitecore 7 with MVC enabled. I have a cshtml layout that has a header, menu, footer and placeholder in it.

当我使用POST方法在页面中提交表单时,它会到达控制器,并且由于某种原因,控制器会返回一个viewresult,只有从viewresult中获取的特定html才会呈现到页面中.这意味着在执行回发后,页眉,菜单,页脚都消失了,只有结果中的html才会呈现在页面上.

When i submit a form in the page with POST method, it gets to the controller and the controller is returning a viewresult for some reason only that particular html from the viewresult gets rendered to the page. Meaning that after doing a postback the header, menu, footer is gone and only the html from the result gets rendered on the page.

这是预期的行为还是我做错了什么?我希望当我进行表单回发时,它也将返回viewresult以及所呈现的布局

Is this behaviour expected or am i doing something wrong? i would expect that when i do form postback it would return the viewresult with the layout rendered as well

推荐答案

我应该使用Html.BeginRouteForm而不是Html.BeginForm

i was supposed to use Html.BeginRouteForm instead of Html.BeginForm

添加此行可解决问题

   @using (Html.BeginRouteForm(Sitecore.Mvc.Configuration.MvcSettings.SitecoreRouteName, FormMethod.Post))
   {
      @Html.Sitecore().FormHandler()
   }

这篇关于Sitecore MVC表单回发不返回完整布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆