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");
}
});
});