【发布时间】:2010-11-05 05:17:43
【问题描述】:
我有以下网络方法:
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=True, XmlSerializeString:=True)> _
Public Function GetDictionary() As Dictionary(Of String, String)
Dim d As New Dictionary(Of String, String)
d.Add("key1", "value1")
d.Add("key2", "value2")
Return d
End Function
如果我从我的 ajax 调用中使用 HttpPost,我可以很好地检索结果 (JSON),但是一旦我使用 HttpGet,我就会得到以下异常:
System.NotSupportedException:类型 System.Collections.Generic.Dictionary`2[[System.String, mscorlib , 版本=2.0.0.0, 文化=中性, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, 版本 =2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] 不受支持,因为它实现了 IDictionary
我想在这里使用 HttpGet 以便可以缓存结果。
我尝试了各种不同的调用方式,但没有运气。有任何想法吗?使用 GET 可以做到这一点吗?
【问题讨论】: