它在CreateTextResponse上的使用我使用VS2010目标框架是3.5 错误:
'System.ServiceModel.Web.WebOperationContext'不包含'CreateTextResponse'的定义,也没有扩展方法'CreateTextResponse'接受类型'System.ServiceModel.Web.WebOperationContext'的第一个参数'(你错过了使用指令或汇编引用吗?)
[OperationContract]
[WebInvoke(UriTemplate = "", Method = "GET",
BodyStyle=WebMessageBodyStyle.Bare,
ResponseFormat = WebMessageFormat.Json)]
public Message Blah()
{
var j = new { Name = "blah1", Data = "blah2" };
JavaScriptSerializer s = new JavaScriptSerializer();
string jsonClient = s.Serialize(j);
return WebOperationContext.Current.CreateTextResponse("method(" + jsonClient + ");",
"application/json; charset=utf-8", Encoding.UTF8);
}
答案 0 :(得分:0)