Отсутствующий параметр в сообщении Ajax в Asmx
Я пытаюсь отправить строкуFile
к моей службе asmx, и я продолжаю получать следующую ошибку:
Message: Invalid web service call, missing value for parameter: File
StackTrace
at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary`2 parameters) at
System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters)\\r\\n at
System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\\r\\n at
System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)\",\"ExceptionType\":\"System.InvalidOperationException\"}
Вот JS
function AJAXActionPostData(service, operation, File, callback, async)
{
if (!async) { async = false; }
$.ajax({
type: 'POST',
url: '/API/Service.asmx/operation',
contentType: 'application/json; charset=utf-8',
async: async,
data: "{ 'File': '" + File + "' }",
dataType: 'json',
success: function (msg) { if (msg) { callback(msg.d); } },
error: ErrorHandler
});
}
когда передается в функцию вышеfile
имеет значение "test \ r \ n" Могут ли экранирующие символы связываться с ним?
Сервисный код
[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public bool UploadCSV(string id, string File)
{
string testfile = File;
return true;
}
Других ошибок нет, толькоFile
не имеющий значения. Я пробовал разные вещи, но не могу понять, что мне не хватает?