Falta el parámetro en la publicación de Ajax a Asmx
Estoy tratando de enviar la cadenaFile
a mi servicio asmx y sigo recibiendo el siguiente error:
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\"}
Aquí está el 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
});
}
cuando pasa a la función anteriorfile
tiene un valor de "prueba \ r \ n" ¿Pueden los caracteres de escape estar jugando con él?
Código de servicio
[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public bool UploadCSV(string id, string File)
{
string testfile = File;
return true;
}
No se lanzan otros errores, solo elFile
No tener un valor. He probado varias cosas pero no entiendo lo que me estoy perdiendo.