3

Primary Question

I have a single form which, depending on various underlying metadata will display different variations of a form. In a single case, only in the deployed application (works fine in dev and qa environments), one variant of the form causes a 500 Internal Server Error. I've examined the data sent back to the server in both the dev and live environments, and there's no difference at all.

The question is, how can I track down this 500 error? I have elmah installed, and its not getting tripped. I've set a Logging statement as the first action in my POST handler, and it never executes. I've set <customErrors mode="Off"/> in my web.config, and it doesn't show me a better error message. The only thing I can think of is that I have some kind of routing issue, but that doesn't really feel right since the same data works just fine to route for other servers.

So, what else can I do to track down this elusive bug?

Background Info

I have a reporting module in the app that I'm building, and it is metadata driven. Once they select which report they wish to execute, the software pulls up the metadata for the report, figures out what parameters need to be collected, and displays a form to gather them from the user. Once the user has filled out the form, they click a button, which submits the form via a jquery $.ajax() call. The controller should pick up the incoming form post, validate the form data, and then either re-display the form or return a json with a url to present the report renderer action.

Route Config

public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } } 

Ajax Post Code

var ajaxUrl = this.action; var ajaxType = this.method; var ajaxData = $(this).serialize(); $.ajax({ url: ajaxUrl, type: ajaxType, data: ajaxData, success: function(result) { // did we get a JSON back from the server? if (typeof(result) === "object") { //deal with the return result... if (window.console) console.log("-- reportParam form submit passed validation"); $("#popupDialog").popup("close"); //need non-ajax version to go to url so we get a dom refresh - we want a new page also // window.location.href = window.open(result.URL, '_blank'); } else { if (window.console) console.log("-- reportParam form failed validation"); $('#popupDialog').html(result); $('#popupDialog').trigger('create'); var _RPT = RevTrak.Portal.Report; _RPT.Index.initBindings(); } }, complete: function() { if (window.console) console.log("-- paramEdit form submit ajax call complete"); //this indicates we passed validation }, error: function(xhr, textStatus, errorThrown) { var sErrMsg = ""; sErrMsg += "paramEdit form submit error "; sErrMsg += "\n\n" + " - textStatus :" + textStatus; sErrMsg += "\n\n" + " - Error Status :" + xhr.status; sErrMsg += "\n\n" + " - Error type :" + errorThrown; sErrMsg += "\n\n" + " - Error message :" + xhr.responseText; if (window.console) console.log(sErrMsg) alert(sErrMsg); } }); 

Thanks!

7
  • please post ajax-code or at least the URL you post to, it could be you are posting directly to some non-extensionless route. AFIK your routing is correct. you described some behaviour that suggests you are not even POSTing to your controller, but to a website directly which would be blocked by your web.config Commented Apr 29, 2013 at 14:44
  • how can that idea reconcile with the idea that it works fine for other servers, and other 'posts'....its the exact same url in every case, just with different form data. Commented Apr 29, 2013 at 14:51
  • was the only possibility i saw... in general HTTP: 500 is thrown when some interaction between client and server failed. if you tell me that it works everywhere else, then there must be a difference in code somewhere. i assume you parse the form in jQuery? in any case i would expect 404 error or some modifier issue (private/internal action) Commented Apr 29, 2013 at 14:54
  • I can't see how there could be any difference in the code...its all metadata driven, so there's only the one bit of code to deal with it for all possibilities. The real question is how to go about tracking down the problem, though, and not what is the specific problem (though I'd be perfectly happy with that too, but I don't want to waste any of your time on things I ought to be able to do...I am just out of ideas) Commented Apr 29, 2013 at 14:57
  • 1
    then i am unfortunately out of ideas Commented Apr 30, 2013 at 7:18

1 Answer 1

2

In this case, the answer was to run the app on the live webserver.

Once I'd done that, I was able to see more details about the error. I had expected that setting <customErrors mode="Off"/> in the web.config would accomplish the same thing, but evidently, I was wrong about that.

Anyhow, after running a browser from the webserver itself, I was able to see that the error was A potentially dangerous Request.Form value was detected from the client (repModel.sQuery=&quot;...ND THEDATE&lt;DATEADD(dd,1,@dtEnd...&quot;)., and thats enough info for me to figure out where to go next.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.