我需要从我的web服务返回一条消息。下面是我的代码示例,并且我返回一个字符串。
[web method]
public string CheckFeedSubmission()
{
string responseText = "";
try
{
//Stuff goes here
responseText = "It Worked!"
}
catch (Exception ex) { responseText = "Opps wehave an error! Exception message:" + ex.Message; }
return responseText ;
}
我目前得到如下回应......
<string xmlns="http://tempuri.org/"/>
我会非常想回到像
{"success" : true, "message" : "***Message Here***"}
我相信的东西,一旦我得到它的想法,我将能够返回其他物品,如果需要的话。它只是我需要解决的基础。
所有帮助非常感谢,提前:)
UPDATE感谢:刚刚发现这个...
return "{Message:'hello world'}"
我会需要这样的东西
responseText = "{"success" : true, "message" : \"There has been an error. Message: " + ex.Message + "\"}"
可能重复[Web服务应返回JSON(http://stackoverflow.com/questions/8205081/web -service-should-return-json) – 2014-02-19 23:47:54