C# devextreme移动应用程序调用webmethod仅返回html源代码
我使用devextreme开发移动应用程序来调用我用c#编写的web方法。调用web方法很成功,但返回的数据都是html源代码。我已经在IIS中为web服务启用了跨源 下面是我用来调用web方法的jquery getC# devextreme移动应用程序调用webmethod仅返回html源代码,c#,jquery,webmethod,devextreme,C#,Jquery,Webmethod,Devextreme,我使用devextreme开发移动应用程序来调用我用c#编写的web方法。调用web方法很成功,但返回的数据都是html源代码。我已经在IIS中为web服务启用了跨源 下面是我用来调用web方法的jquery get $.get('http://192.168.2.104:81/TwinCatWebServices.aspx/writetempo2', { btempo2: "'" + viewModel.btempo + "'" }).done(function (result) {
$.get('http://192.168.2.104:81/TwinCatWebServices.aspx/writetempo2', { btempo2: "'" + viewModel.btempo + "'" }).done(function (result) {
//result is your data
alert("success");
console.log(result);
})
.error(function (result) {
alert(result);
console.log(result);
})
我的web方法如下所示
[WebMethod]
public static string writetempo2(string btempo2)
{
string test = "ABC";
return test;
}
我也尝试过这个,但也是一样的
[WebMethod]
public static string writetempo2(string btempo2)
{
string test = "ABC";
var oseries = new System.Web.Script.Serialization.JavaScriptSerializer();
return oseries.Serialize(test);
}
在浏览器控制台中,我看到返回结果如下:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
</title></head>
<body>
<form method="post" action="writetempo2?btempo2=%27true%27" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="zTMjjnpAKtBaBVL8P2JeyNhoLSPcdk68uxF2AbXAU31Qqyfd/
EvogsxQHknxMsghbF9k1bnXDwsxk9A5rVojBH6vLrHV1f4/eOz1OKbEXno=" />
</div>
<div>
AAAAAA
</div>
</form>
</body>
</html>
AAAAA
我犯了多大的错误。请帮助。尝试使用.ashx处理程序 你可以看到这个例子