Or this post could even be entitled “Why I have no hair and will never have hair” but it’s not very helpful as far as describing the problem goes.

So I found myself in some new kind of hell today trying to debug an error that was not an error.

The project I was working on today is an MVC5 project that uses Redactor for editing HTML. The Model that the edit form posts back to perform an update contains a field that contains the HTML markup from Redactor. This isn’t just a plain old HttpPost however as it does so via Ajax and OnSuccess of the post fires off a javascript function and process the result. Markup and function shown below:

Razor View

@model VoiceProject.Models.SurveyEditBaseModel

AjaxOptions options = new AjaxOptions();
options.HttpMethod = “Post”;
options.OnSuccess = “SubmitUpdateSurveyComplete”;


@using (Ajax.BeginForm(“UpdateSurvey”, “Home”, null, options
, new { @class = “form-horizontal”, id = “FormUpdateSurvey” }))

// The rest of the form

MVC Action

public ActionResult UpdateSurvey(SurveyEditBaseModel model){```

    // Error handling removed for brevity

bool result = Engine.EditSurvey(


, model.UnitPersonRated

, model.StartOn

, model.EndOn

, model.FirstName

, model.LastName

, model.Email

, model.Phone

, model.Organisation

, model.Department

, model.Position

, model.Industry

, model.Sector

, model.Size

, model.Country

, model.OrganiserMessage

, model.TimeZone);```

if (result == false)
return Json(new JsonResultModel(false, “Error updating survey.”), JsonRequestBehavior.AllowGet);
JsonResultModel jsonResult = new JsonResultModel(true);
return Json(jsonResult, JsonRequestBehavior.AllowGet);

Javascript Function

function SubmitUpdateSurveyComplete(data) {<br></br>
if (data.Success) {<br></br>
InfoMessage("Your survey was updated successfully")<br></br>
} else {<br></br> NotifyErrors(data);<br></br>
}<br></br> }

The SubmitUpdateSurveyComplete function is called and receives a Json object from the call to UpdateSurvey.

So the fun started when the UpdateSurvey method was executing just fine and no error was occurring. It got to the line return Json(jsonResult, JsonRequestBehavior.AllowGet); and that executed just fine thanks. Tracing it through the code all went well until my custom error code got hit but not a sniff of an error could be seen.

I checked my Elmah log but nothing. I monitored what was occurring using Glimpse and still nothing out of the ordinary except for the fact that my Error page was being returned (the full markup in the data parameter of SubmitUpdateSurveyComplete instead of the Json object that should have been returned.

Looking at what was passing across the wire in the model the obvious cause of the issue was the fact that when something was entered in to Redactor and hence markup was submitted with the Post the whole thing failed. But why? I had set [ValidateInput(false)] to false so it should accept the markup fine.

Well it turned out in the end to be that I was missing the requestValidationMode=”4.0″ attribute on the httpRuntime element of the web.config

The nightmare is over.