ottengo il seguente errore "Web Service nome di un metodo non è valido" quando provo a chiamare webmethod da JavaScriptWeb nome del metodo di servizio non è valido
System.InvalidOperationException: SaveBOAT Web Service nome di un metodo non è valido . su System.Web.Services.Protocols.HttpServerProtocol.Initialize() su System.Web.Services.Protocols.ServerProtocol.SetContext (tipo Tipo, contesto HttpContext, richiesta HttpRequest, risposta HttpResponse) su System.Web.Services.Protocols .ServerProtocolFactory.Create (tipo tipo, HttpContext contesto, HttpRequest richiesta, HttpResponse risposta, booleano & abortProcessing) Codice
HTML:
<asp:LinkButton runat="server" ID="lnkAddBoat" OnClientClick="javascript:AddMyBoat(); return false;"></asp:LinkButton>
JS Codice:
function AddMyBoat() {
var b = document.getElementById('HdnControlId').value;
jQuery.ajax({
type: "GET",
url: "/AllService.asmx/SaveBOAT",
data: { Pid: b },
contentType: "application/text",
dataType: "text",
success: function(dd) {
alert('Success' + dd);
},
error: function(dd) {
alert('There is error' + dd.responseText);
}
});
}
codice C# (metodo Web in file di AllService.asmx)
[WebMethod]
public static string SaveBOAT(int Pid)
{
// My Code is here
//I can put anythng here
SessionManager.MemberID = Pid;
return "";
}
Ho provato tutte le soluzioni trovate su Stack Overflow e ASP.NET site.but nessuno di loro ha lavorato per me.
nel mio caso manca la parola chiave pubblica – Naga