针对营销人员的网络表单上的“保存操作"会引发异常 [英] Save Action on webforms for marketers throws exception

查看:115
本文介绍了针对营销人员的网络表单上的“保存操作"会引发异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用最新版本的Sitecore-7.2(rev.140228)和最新版本的WFFM-2.4 rev. 140923.所以问题是无论我执行哪种保存操作,无论何时我尝试提交表单,Sitecore都会引发异常:

I am using the latest version of Sitecore - 7.2 (rev. 140228) and the latest version of WFFM - 2.4 rev. 140923. So the problem is whenever I try to submit a form no matter what kind of save action I have, Sitecore throws exception:

对象引用未设置为对象的实例.

Object reference not set to an instance of an object.

描述:发生未处理的异常.

Description: An unhandled exception occurred.

异常详细信息:System.NullReferenceException:对象引用未设置为对象的实例.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

堆栈跟踪:

[NullReferenceException: Object reference not set to an instance of an object.]
   Sitecore.Forms.Mvc.Controllers.ModelBinders.FormModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +571
   System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +457
   System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +152
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +641

一些其他信息. WFFM的最新版本支持MVC,因此在这种情况下,我使用cshtml布局.这是描述如何使用MVC的博客文章-

Some additional information. The latest version of WFFM supports MVC so in this scenario I use cshtml layout. This is the blog post where is described how to use MVC - THIS Despite it is for previous versions of SC it doesn't matter and the solution is applicable for the latest version.

推荐答案

认为我对此有解决方案.

Think I have a solution for this.

我使用在使用ILSpy反映Sitecore.Forms.MVC类后创建的控制器和模型绑定程序的版本进行反向工程和调试.

I reverse engineered and debugged using a version of the controller and model binder I created after reflecting on the Sitecore.Forms.MVC classes using ILSpy.

null引用显然是在引用时出现的:

Apparently the null reference is occuring when it hits this:

if (controllerContext.HttpContext.Request.RequestType == "POST" && formId != item.ID)

itemnull. item设置在前面的行中:

item is null. item is set in the line before:

Sitecore.Data.Items.Item item = RenderingContext.CurrentOrNull.PageContext.Database.GetItem(RenderingContext.CurrentOrNull.Rendering.DataSource);

数据源属性在呈现中为空.如果您查看演示文稿的详细信息,则会看到这是因为还有另一个用于指定表单ID的字段.显然,这看起来像是一个Sitecore错误.但是一个简单的解决方法是在表单ID和呈现的数据源"属性中都设置表单数据源.

The data source property is empty on the rendering. If you check your presentation details, you'll see that's because there is another field that is used to specify your form ID. Apparently this looks like a Sitecore bug. But an easy workaround is to set the form data source in both the form ID and the Data source property of the rendering.

这篇关于针对营销人员的网络表单上的“保存操作"会引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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