I'm hoping someone can shed some light on why I may be receiving a 405 errors on my ASP.Net VB.Net WebMethod when attemping to call from JQuery ajax method.
Server Implementation:
<WebMethod()> _
Public Shared Function DoSomething(id As String) As String
Dim vm As HssViewModel = New HssViewModel()
Dim jResult As String = JsonConvert.SerializeObject(vm)
Return jResult
End Function
Javscript Implementation:
$.ajax({
type: "POST",
url: "mypage.aspx/DoSomething",
contentType: "application/json; charset-utf-8",
data: { 'id': 'ABC12345' },
dataType: "json",
cache: true,
succes: function (data) {
context = data;
console.log(data);
},
error: function (err) {
console.log("JQUERY ERROR RESPONSE: " + err.message);
}
});
I am consistently receiving the following error message:
POST http://localhost/mypage.aspx/DoSomething 405 (Method Not Allowed)
I have also tried setting up the script method tag to allow a GET request but then I receive a 404
<ScriptMethod(UseHttpGet:=True, ResponseFormat:=ResponseFormat.Json)> _