【发布时间】:2012-06-20 21:27:46
【问题描述】:
我正在尝试输出正确包装的 JSONP 值以供 jQuery 使用。
我正在寻找的输出是:
jsoncallback({"Status": "OK"})
但是它输出的atm:
"jsoncallback({"Status": "OK"})"
显然这不是正确的 JSONP 格式,因为 jQuery 请求无法处理响应。
我在 C# 中的 OperationContract 是:
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "returndata?s={s}")]
Stream EchoWithGet(string s);
public string EchoWithGet(string s)
{
string json = @"jsoncallback({'Status':'OK'})";
Console.WriteLine("Call Made: " + s);
return json;
}
我尝试使用JSON.NET 和System.Web.Script 命名空间来使用JavaScriptSerializer。
但没有什么对我有用,我真正想做的就是去掉两个双引号。
【问题讨论】:
-
wpf 和这个有什么关系?
-
我正在使用 WPF 环境,所以我想迎合这一点。通常我最终会得到与 ASP 相关的答案,但它无济于事
标签: c# wpf wcf web-services jsonp