I have two project such as Main Project in Dot net Core MVC and Target project in ASP.NET framework webforms I have a Test Method in Webform in Target Project , But I want access the method from Main project using jQuery Ajax But this Code Does not hit the target Method..
From Main Project
$('#btnTest').click(function () {
AjaxCall();
});
function AjaxCall() {
$.ajax({
type: 'GET',
crossDomain: true,
dataType: 'jsonp',
url: 'https://localhost:44332/WebForm1.aspx/TestMethod',
success: function (jsondata) {
alert('Success');
},
error: function (request, error) {
alert("Failed");
}
})
}
</script>
//Target Project Code behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
namespace TargetProject
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static string TestMethod()
{
return "Success";
}
}
}