我在一台服务器 1 上编写了一个 asmx 服务,在另一台服务器 2 上编写了 asp.net/c#。
我要转一个dictionary<string,string>
从 srv1 到 srv2。
我读到 Dictionary is not serializable and should be sent as List<KeyValuePair<string,string>>
.
在 srv2 上,我尝试读取结果,但它的类型是:
KeyValuePairOfStringString[] result = response.GetTemplatesParamsPerCtidResult;
我尝试检索键、值但不能展开每个元素:
foreach (var pair in result)
{
// pair has just 4 generic methods: toString, GetHashCode,GetType,Equals
}
我该怎么做?在我的实现中有什么我应该改变的吗?
TIA
最佳答案
如何使用数组 MyModel[]
,其中 MyModel
如下所示:
public class MyModel
{
public string Key { get; set; }
public string Value { get; set; }
}
在公开 SOAP 网络服务时应避免使用泛型。
关于c# - 从服务器端调用 asmx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7501098/