Click here to Skip to main content
15,902,198 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Experts,


I am Doing an ASP.net project. In that project i am using Ajax JSON to transfer data to webmethod..

i have used this technology in many pages. but everything is working fine,
Expect one.

That one , i tried to used to transfer bulk data to webmethod. But it is not working fine, In my local Project it is working fine....

When i put the files to live server then ajax JSON throw an error
ie : "500: Internal Server Error".

PLease help me to solve this issue..


Thanks and Regards,

Dileep
Posted
Updated 29-Apr-13 1:06am
v2

1 solution

 
Share this answer
 
Comments
shraddha patel 2021 4-Apr-22 1:13am    
Hello

ajax call webmethod to sometimes internal server error throw please solution

function saveanswerwithrec() {
debugger;
var UserAnswerText = $('#Hdn_AnswerText').val();
var AnswerTextBack = '<%=AnswerText%>';
var ResultID = <%= ResultID%>;
var TestID = <%= TestID%>;
var UserID = <%= UserID%>;
var AnswerID = <%= AnswerID%>;
var QuesID = <%= QuesID%>;
var TestSetID = <%= TestSetID%>;

if (AnswerTextBack == '')
AnswerTextBack = '0';

$.ajax({
type: "POST",
url: "/users/NewTest.aspx/StopSaveAnswer",
contentType: "application/json; charset=utf-8",
data: "{'RId':'" + ResultID + "','HiddenText':'" + UserAnswerText + "','AnswerText':'" + AnswerTextBack + "','TestID':'" + TestID + "','UserID':'" + UserID + "','AnswerID':'" + AnswerID + "','QuesID':'" + QuesID + "','TestSetID':'" + TestSetID + "'}",
datatype: "json",
async: true,
cache: false,
success: function (success) {
debugger;
alert("successsssss");
$('#Hdn_AnswerText').val('');
$('.recodingStatus').text('Your answer has been uploaded successfully.').show();
},
error: function (error) {
//$('.recodingStatus').text('Your answer has been uploaded successfully.').show();
}
});
}




[WebMethod]
[ScriptMethod(UseHttpGet = false)]
public static bool StopSaveAnswer(Int64 ResultID, string HiddenText, string AnswerText, Int64 TestID, Int64 UserID, Int64 AnswerID, Int64 QuesID, Int64 TestSetID)
{
Int16 ResultStatus = 0;
CommonLib.WriteFile("ResultID - " + ResultID);
try
{
DateTime LocalTime = CommonLib.LocalDateTimeByBranchID(CommonLib.SessionBranchID());
if (HiddenText.StartsWith("data:audio/mp3;base64,"))
{
Byte[] Byts = Convert.FromBase64String(HiddenText.Replace("data:audio/mp3;base64,", ""));
String FileName = "/uploaded_files/" + Guid.NewGuid().ToString() + ".mp3";

string FilePath = HttpContext.Current.Server.MapPath("~" + FileName);
File.WriteAllBytes(FilePath, Byts);
AnswerText = FileName;
}
else
AnswerText = HiddenText;

ResultID = CCLTestresult.SaveRecord(ResultID, TestID, UserID, 0, LocalTime, 0, "", 0, 0, 0);
Int64 RtnAnsID = CCLQuesanstable.SaveRecord(AnswerID, int.Parse(QuesID.ToString()), AnswerText, UserID, "1", 0, ResultID, 0, "", 0);

AnswerText = "";
if (ResultStatus == 1)
{
DBConnection.ExecuteQuery("update ccl_testresult set resultStatus=1 where resultID in(select resultID from ccl_testresult inner join ccl_testtable on resultTestID=TestID where resultUserID=" + UserID + " and TestSetID=" + TestSetID + ")");
}
}
catch (Exception e)
{
//String EmailBody = "Test=" + Ltr_Title.Text + "" + "QuesID=" + QuesID + "" + "UserID=" + UserID + "" + "IsAnswered=" + IsAnswered + "";
//EmailBody += e.Message + "" + e.StackTrace + "";
//EmailBody += "AnswerText:" + Hdn_AnswerText.Value;
//WebEmail.SendEmail("webzeb.stuti@gmail.com", "CCL Tutorials - New Practice Test Error", EmailBody);
return false;
shraddha patel 2021 4-Apr-22 1:14am    
Hello

ajax call webmethod to sometimes internal server error throw please solution

[WebMethod]
[ScriptMethod(UseHttpGet = false)]
public static bool StopSaveAnswer(Int64 ResultID, string HiddenText, string AnswerText, Int64 TestID, Int64 UserID, Int64 AnswerID, Int64 QuesID, Int64 TestSetID)
{
Int16 ResultStatus = 0;
CommonLib.WriteFile("ResultID - " + ResultID);
try
{
DateTime LocalTime = CommonLib.LocalDateTimeByBranchID(CommonLib.SessionBranchID());
if (HiddenText.StartsWith("data:audio/mp3;base64,"))
{
Byte[] Byts = Convert.FromBase64String(HiddenText.Replace("data:audio/mp3;base64,", ""));
String FileName = "/uploaded_files/" + Guid.NewGuid().ToString() + ".mp3";

string FilePath = HttpContext.Current.Server.MapPath("~" + FileName);
File.WriteAllBytes(FilePath, Byts);
AnswerText = FileName;
}
else
AnswerText = HiddenText;

ResultID = CCLTestresult.SaveRecord(ResultID, TestID, UserID, 0, LocalTime, 0, "", 0, 0, 0);
Int64 RtnAnsID = CCLQuesanstable.SaveRecord(AnswerID, int.Parse(QuesID.ToString()), AnswerText, UserID, "1", 0, ResultID, 0, "", 0);

AnswerText = "";
if (ResultStatus == 1)
{
DBConnection.ExecuteQuery("update ccl_testresult set resultStatus=1 where resultID in(select resultID from ccl_testresult inner join ccl_testtable on resultTestID=TestID where resultUserID=" + UserID + " and TestSetID=" + TestSetID + ")");
}
}
catch (Exception e)
{
//String EmailBody = "Test=" + Ltr_Title.Text + "" + "QuesID=" + QuesID + "" + "UserID=" + UserID + "" + "IsAnswered=" + IsAnswered + "";
//EmailBody += e.Message + "" + e.StackTrace + "";
//EmailBody += "AnswerText:" + Hdn_AnswerText.Value;
//WebEmail.SendEmail("webzeb.stuti@gmail.com", "CCL Tutorials - New Practice Test Error", EmailBody);
return false;
}
return true;
}
shraddha patel 2021 4-Apr-22 3:12am    
please reply

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900