What would cause a MVC4 controller to only return a status code and no partial view?
ajax, asp.net-mvc-4, c#, jquery
Solution
Adding to @STW 's answer, try adding to your web.config
<system.webServer>
<httpErrors errorMode=”Detailed” />
</system.webserver>
to see the IIS error response.
Also see these links for more
Understanding 400 Bad Request Exception and ASPNET MVC IIS7 and Bad Request
Problem
This is sort of an odd question but then I have a very odd situation. On my development server (IIS & IIS Express) I make a ajax request and return a form. The user then posts the form back via an ajax post and if there are any validation errors the controller sends back the partial view with a response code of 400. In my ajax method I intercept any 400 errors and redisplay the form with the validation errors. My problem is that when I upload my app to my production server all I get on a validation error is the 400 response with no partial view. I don't know even where to begin? Here is what I have tried, what libraries I am using, and some sample code. ASP.net MVC4, Fluent Validation, jQuery, unobtrusive validation, malsup-ajaxsubmit On my production server... - My partial view that loads the form works as expected. This tells me that the application is having no problem finding my view as the same view is redisplayed if validation fails. - My controller using fluent validation is correctly detecting a model state error and responding with a 400 (just no view with it). - My ajax post using ajaxsubmit is posting to the server correctly using ajax. - Using firebug I step through my ajax method and an 400 error is indeed returned but the only content on xhr.responseText is "Bad Request". NO partial view. Again my development machine works perfectly. Here is some code. My Form Get Request: ``` public ActionResult CreateMedicalEvent(int userId) { var model = new EventModel { MedicalEventUserId = userId }; return PartialView("_Event.Create", model); } ``` My Form Post: ``` [HttpPost] public ActionResult CreateMedicalEvent(EventModel model) { if (!ModelState.IsValid) { Response.StatusCode = 400; return PartialView("_Event.Create", model);//this does not get returned on production server } //the rest of my code if validation passess } ``` My ajax method: ``` $('.se-form').ajaxForm({ delegation: true, beforeSubmit: function() { ajaxHelpers.modalProcess();//modal progress bar }, success: function(data) { $.modal.close(); //handle a successful post }, error: function(xhr) { $.modal.close(); if (xhr.status == 400) { slideEdit.seObj.empty();//this is my form object slideEdit.seObj.append(xhr.responseText);//all I get is "Bad Request" from production server $.validator.unobtrusive.parse($('form', slideEdit.seObj)); ajaxHelpers.bindDates(); //because we need to bind event AND format date, we have to do this here utilities.formatDecimal(); } else { ajaxHelpers.exc(xhr); } } }); ``` I wish there was more code to post but this isn't all that complicated. Am I missing some weird dll file on my production server? Both servers have MVC4 installed. Lost. Pleas help. Thanks.