IIv*_*nov 1 sitecore submit nullreferenceexception web-forms-for-marketers
我使用的是最新版本的Sitecore - 7.2(rev.140228)和最新版本的WFFM - 2.4 rev.140923.所以问题是无论何时我尝试提交表单,无论我有什么样的保存操作,Sitecore都会抛出异常:
你调用的对象是空的.
描述:发生了未处理的异常.
异常详细信息:System.NullReferenceException:未将对象引用设置为对象的实例.
堆栈跟踪:
[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
Run Code Online (Sandbox Code Playgroud)
一些额外的信息.最新版本的WFFM支持MVC所以在这种情况下我使用cshtml布局.这是博客文章,其中描述了如何使用MVC - 这虽然它适用于以前版本的SC,但无关紧要,该解决方案适用于最新版本.
小智 10
想想我有一个解决方案.
我使用我在Sitecore.Forms.MVC使用的类反映后创建的控制器和模型绑定器的版本进行了逆向工程和调试ILSpy.
显然,null当它碰到这个时,它就会出现:
if (controllerContext.HttpContext.Request.RequestType == "POST" && formId != item.ID)
Run Code Online (Sandbox Code Playgroud)
item是null.item在之前的行中设置:
Sitecore.Data.Items.Item item = RenderingContext.CurrentOrNull.PageContext.Database.GetItem(RenderingContext.CurrentOrNull.Rendering.DataSource);
Run Code Online (Sandbox Code Playgroud)
渲染时数据源属性为空.如果您查看演示文稿详细信息,您会看到这是因为还有另一个字段用于指定您的表单ID.显然这看起来像一个Sitecorebug.但一个简单的解决方法是在呈现的表单ID和数据源属性中设置表单数据源.
| 归档时间: |
|
| 查看次数: |
2055 次 |
| 最近记录: |