I'm working on this website, trying to call a function from a C# DLL through default.asmx.cs
It works fine with .NET version 3.5, but our production site is .NET 2.0
I'm using a simple ajax request to call the method in default.asmx
and from there to the DLL. I found that I can not use [WebMethod] in NET2, what could be the other way to work around this?
//this is th开发者_如何学JAVAe Handler
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[System.Web.Services.WebMethod]
public static string removeAutoRecharge(string custServiceid)
{
Class1 jp = new Class1();
return jp.removeCustomerAutoRecharge(custServiceid);
}
}
//Ajax call:
$.ajax({
type: "Post",
url:"default.asnx/removeAutoRecharge",
data: "{custId:123}",
contentType: "application/json; charset=utf-8",
dataType: "json",
complete:function (xhr, status)
{
alert(xhr.responseText);
alert(xhr.status);
},
success: function(result)
{
$('#AutoMSG').html(result.d);
},
error: function(xmlHttpRequest, status, err)
{
$('#AutoMSG').html("error!")
}
});
Do you have the source code for this dll? [WebMethod] works in .net 2. Perhaps you can modify the project that created that binary, and make it a .net 2 project.
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
This I ran using .net 2 project:
精彩评论