Reputation: 157
We are trying upload pictures to our server. Its working fine in http sites, but not in https sites.
It throws following: Failed to load resource: the server responded with a status of 500 (Internal Server Error)
Here is the code which is used for ajax
Java Script
function fnTest(){
var iTaskID = $("#hdnCurTaskID").val();
var files = $("#TaskImg")[0].files;
if (files.length > 0) {
if (files.length > 3) {
alert("Maximum 3 files Allowed");
return;
}
if (typeof FormData == "undefined") {
var postdata = [];
for (var i = 0; i < files.length; i++) {
postdata.push("UploadedFile", files[i]);
}
postdata.push("TaskID", iTaskID);
}
else {
var postdata = new FormData();
for (var i = 0; i < files.length; i++) {
postdata.append("UploadedFile", files[i]);
}
postdata.append("TaskID", iTaskID);
}
$.ajax({
type: "POST",
url: "TaskStatus.asmx/UploadExecTaskPic",
contentType: false,
processData: false,
async: false,
responseType: "json",
data: postdata,
success: function (result) {
var MaxFile = GetSessionValuecurrent(iTaskID);
if (MaxFile == "MaxFile") {
alert("Maximum 3 Files only Allowed to Upload");
}
else {
$("#TaskImg").val("");
$("#TaskImg").replaceWith($("#TaskImg").clone());
DoCloseFileSelector();
DoShowTaskImages(iTaskID, '');
}
},
error: function () {
alert("Upload Error");
}
});
}
}
Web Method:
[WebMethod(EnableSession = true)]
public string UploadExecTaskPic()
{
string sResult = string.Empty;
return sResult;
}
Upvotes: 0
Views: 257
Reputation: 424
I came across this information in a google search
FIX Request format is unrecognized for URL unexpectedly ending in
Add the following to web.config since GET and POST are disabled by default in ASP.NET 2.0 and greater:
<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
</configuration>
Upvotes: 1