c# - 从服务器端调用 asmx

标签 c# .net asp.net web-services

我在一台服务器 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/

相关文章:

c# - "Context cannot be used while the model is being created"异常与 ASP.NET 标识

c# - 在 ASP.NET 中设置 DropDownList 的值

c# - 使用 C# 阻止应用程序

c# - 如何在 C# 中找到内存被用完的地方?

c# - 将 datagridview 列值存储在变量中

c# - 像 MS Paint 一样调整位图的大小 - 没有抗锯齿

.net - 使用 Newtonsoft.Json 解析 json 时出现 RuntimeBinderException

c# - 为运输问题优化生成一系列非等成本的算法

c# - ILogger 不使用 Serilog 写入控制台

.net - 内容文件更改后 Visual Studio 未重建