Following are the WebService method i am trying to consume-:
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
using ajax call for calling this method
$.ajax({
type: "POST",
url: "/WebServices/WebService1.asmx/HelloWorld",
data: "{}",
contentType: "application/json; charset=utf-8",
success: function (msg) {
var data = msg.d;
},
error: function (msg) {
alert(msg.responseText);
}
});
But everytime i am getting error of resource not found might be because i am calling it from MVC view, i also tried to put whole localhost path http://localhost:60005/ still got the error of resource not found, could someone give me a small example of calling asmx webservice from MVC view?
Try with adding this line to your RouteConfig:
routes.IgnoreRoute("{*x}", new { x = @".*\.asmx(/.*)?" });
also, uncomment this line in your asmx web service class:
[System.Web.Script.Services.ScriptService]
you have a nice tutorial here :
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.