1
votes

In our ASP.NET MVC 4 web application, we are getting the following error on our staging server. Via Google Chrome debug Tool window we trap this error when a POST call to an Action Method is made on the client side via AJAX:

POST http://StagingServerURL/ControllerName/ActionMethodName 500 (Internal Server Error)

The application is deployed, with exact same code and database, on a Development machine and the Production Server as well and it works on both of these two machines just fine. The three machines have the following settings:

  • Development machine: Windows 7 Professional, IIS 7.5, SQL Server 2008 R2
  • Production: Windows Server 8 R2, IIS 7.5, SQL Server 2008 R2
  • Staging: Windows Server 2012 R2 standard, IIS 8.5, SQL Server 2008 R2

Action Method:

public ActionResult SaveData(FormCollection collection)
{
    try
    {
        ...code to insert data to SQL Server Db...
        }
        db.SubmitChanges();
        System.IO.File.Copy(Server.MapPath("~/FolderName/File1Name.txt,Server.MapPath("~/FolderName/File2Name.txt,true);

        return Json("");
    }
    catch (Exception e)
    {
        throw e;
    }
}

AJAX Call:

$('#submitButton').click(function () {
    var data = $('form').serializeObject();
    $.ajax({
        url: '@Url.Action("SaveData")', type: "POST",
        data: data,
        success: function (data) {
            $('#Status').show().fadeOut(8000);
        },
        error: function (data) {
            alert("An error occured");
        }
    });
});
1
Instantly the copying of a file catches my eye and permissions come to mind. You haven't given any details on debugging. If you comment out the file copying, does the problem persist? What is the actual error being returned? Internal 500 doesn't give us much to work with. Try to output more details.Rowan Freeman
The staging server does not have Visual Studio installed and the other servers do have the issue. How can I get detail error message through Google Chrome Dev tool?nam
The page can output more information. More than just error 500.Rowan Freeman
@RowanFreeman, I could not figure out how to display the server-side error on the client side using Google Chrome Dev Tools. Is there some setting in the Web.config file that I need to make to get the server side error in the Chrome Debugging tool? If so, what that setting would be?nam

1 Answers

1
votes

Solution 1: Change the IIS 8.5 settings in error page for 500 internal server error to Detailed error message instead of Detailed errors for local requests and Custom error pages for remote requests.

I hope this can resolve.

Solution 2: From the code,I assume you are missing this JSON("",JsonRequestBehavior.AllowGet)