CustomForms: TextField content not saved using Html display option

Topics: Customizing Orchard
Jun 25, 2012 at 6:20 PM

(Note - cross-posted this at the CustomForms project site as well ...)

Hello - I've been using the CustomForms module on a couple of Orchard projects now, really liking it. Just ran into an issue though: changing the display options to "Html" prevents the associated field from being saved.

The issue is a HttpRequestValidationException being thrown due to "< >" tags in the content. I've gone over my web.config settings and all seems well there. Seems to be a deeper-in-the-stack MVC issue. I can't even hit the exception using the debugger. Any thoughts / ideas?

Thanks! Again, love the module.

The error (from the logs):

2012-06-25 10:08:16,733 [16] Orchard.ContentManagement.Drivers.Coordinators.ContentFieldDriverCoordinator - HttpRequestValidationException thrown from IContentFieldDriver by Orchard.Core.Common.Drivers.TextFieldDriverSystem.Web.HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (ClassifiedAdPart.Message.Text="<p>First crack at an...").
Server stack trace:    at System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection)   at Microsoft.Web.Infrastructure.DynamicValidationHelper.ValidationUtility.CollectionReplacer.<>c__DisplayClass12.<ReplaceCollection>b__d(String value, String key)   at Microsoft.Web.Infrastructure.DynamicValidationHelper.LazilyEvaluatedNameObjectEntry.ValidateObject()   at Microsoft.Web.Infrastructure.DynamicValidationHelper.LazilyValidatingHashtable.get_Item(Object key)   at System.Collections.Specialized.NameObjectCollectionBase.FindEntry(String key)   at System.Collections.Specialized.NameValueCollection.GetValues(String name)   at System.Web.Mvc.NameValueCollectionValueProvider.ValueProviderResultPlaceholder.GetResultFromCollection(String key, NameValueCollection collection, CultureInfo culture)   at System.Web.Mvc.NameValueCollectionValueProvider.ValueProviderResultPlaceholder.<>c__DisplayClass4.<.ctor>b__0()   at System.Lazy`1.CreateValue()
Exception rethrown at [0]:    at System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection)   at Microsoft.Web.Infrastructure.DynamicValidationHelper.ValidationUtility.CollectionReplacer.<>c__DisplayClass12.<ReplaceCollection>b__d(String value, String key)   at Microsoft.Web.Infrastructure.DynamicValidationHelper.LazilyEvaluatedNameObjectEntry.ValidateObject()   at Microsoft.Web.Infrastructure.DynamicValidationHelper.LazilyValidatingHashtable.get_Item(Object key)   at System.Collections.Specialized.NameObjectCollectionBase.FindEntry(String key)   at System.Collections.Specialized.NameValueCollection.GetValues(String name)   at System.Web.Mvc.NameValueCollectionValueProvider.ValueProviderResultPlaceholder.GetResultFromCollection(String key, NameValueCollection collection, CultureInfo culture)   at System.Web.Mvc.NameValueCollectionValueProvider.ValueProviderResultPlaceholder.<>c__DisplayClass4.<.ctor>b__0()   at System.Lazy`1.CreateValue()   at System.Lazy`1.LazyInitValue()   at System.Lazy`1.get_Value()   at System.Web.Mvc.NameValueCollectionValueProvider.GetValue(String key, Boolean skipValidation)   at System.Web.Mvc.ValueProviderCollection.GetValueFromProvider(IValueProvider provider, String key, Boolean skipValidation)   at System.Web.Mvc.ValueProviderCollection.<>c__DisplayClass9.<GetValue>b__4(IValueProvider provider)   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)   at System.Web.Mvc.ValueProviderCollection.GetValue(String key, Boolean skipValidation)   at System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)   at System.Web.Mvc.DefaultModelBinder.GetPropertyValue(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor, IModelBinder propertyBinder)   at System.Web.Mvc.DefaultModelBinder.BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor)   at System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext controllerContext, ModelBindingContext bindingContext)   at System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Object model)   at System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext)   at System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)   at System.Web.Mvc.Controller.TryUpdateModel[TModel](TModel model, String prefix, String[] includeProperties, String[] excludeProperties, IValueProvider valueProvider)   at System.Web.Mvc.Controller.TryUpdateModel[TModel](TModel model, String prefix, String[] includeProperties, String[] excludeProperties)   at Orchard.CustomForms.Controllers.ItemController.Orchard.ContentManagement.IUpdateModel.TryUpdateModel[TModel](TModel model, String prefix, String[] includeProperties, String[] excludeProperties)   at Orchard.Core.Common.Drivers.TextFieldDriver.Editor(ContentPart part, TextField field, IUpdateModel updater, Object shapeHelper) in C:\Shared\Projects\Clients\PembertonHeights\src\Orchard.Web\Core\Common\Drivers\TextFieldDriver.cs:line 70   at System.Dynamic.UpdateDelegates.UpdateAndExecute5[T0,T1,T2,T3,T4,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)   at Orchard.ContentManagement.Drivers.ContentFieldDriver`1.<>c__DisplayClass13.<Orchard.ContentManagement.Drivers.IContentFieldDriver.UpdateEditorShape>b__12(ContentPart part, TField field) in C:\Shared\Projects\Clients\PembertonHeights\src\Orchard\ContentManagement\Drivers\ContentFieldDriver.cs:line 46   at Orchard.ContentManagement.Drivers.ContentFieldDriver`1.<>c__DisplayClass2a.<Process>b__28(<>f__AnonymousType10`2 pf) in C:\Shared\Projects\Clients\PembertonHeights\src\Orchard\ContentManagement\Drivers\ContentFieldDriver.cs:line 87   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)   at Orchard.ContentManagement.Drivers.ContentFieldDriver`1.Process(ContentItem item, Func`3 effort) in C:\Shared\Projects\Clients\PembertonHeights\src\Orchard\ContentManagement\Drivers\ContentFieldDriver.cs:line 88   at Orchard.ContentManagement.Drivers.ContentFieldDriver`1.Orchard.ContentManagement.Drivers.IContentFieldDriver.UpdateEditorShape(UpdateEditorContext context) in C:\Shared\Projects\Clients\PembertonHeights\src\Orchard\ContentManagement\Drivers\ContentFieldDriver.cs:line 45   at Orchard.ContentManagement.Drivers.Coordinators.ContentFieldDriverCoordinator.<>c__DisplayClassf.<UpdateEditor>b__e(IContentFieldDriver driver) in C:\Shared\Projects\Clients\PembertonHeights\src\Orchard\ContentManagement\Drivers\Coordinators\ContentFieldDriverCoordinator.cs:line 70   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\Shared\Projects\Clients\PembertonHeights\src\Orchard\InvokeExtensions.cs:line 19

Coordinator
Jun 25, 2012 at 9:04 PM

Can you file a bug for that with a repro ?