0

I using devextreme to develop mobile apps to call my web method wrote in c#. It is success call the web method but the data return is all html source code. I has enable the cross origin in the IIS for the web service.

Below is the jquery get i use to call the web method.

  $.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);
        })

my web method as below

 [WebMethod]
    public static string writetempo2(string btempo2)
    {


        string test = "ABC";            

        return test;

    }

I try this as well but also the same

 [WebMethod]
    public static string writetempo2(string btempo2)
    {            
        string test = "ABC";

        var oseries = new System.Web.Script.Serialization.JavaScriptSerializer();
        return oseries.Serialize(test);

    }

In the browser console, i saw the return result as below:

<!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>

What the mistake I make. Please help.

Lachlan Dowding
  • 4,356
  • 1
  • 15
  • 18
Bubble Bub
  • 651
  • 4
  • 12
  • 32

1 Answers1

0

Try to use .ashx handler.

You can see the example here

Sergey
  • 5,396
  • 3
  • 26
  • 38