C# Asp.net WebService无法转换类型为';System.Int32';至ty…;neric.IDictionary`2[System.String,System.Object]';

C# Asp.net WebService无法转换类型为';System.Int32';至ty…;neric.IDictionary`2[System.String,System.Object]';,c#,asp.net,angular,web-services,asmx,C#,Asp.net,Angular,Web Services,Asmx,我一直在尝试使用Angular调用Web服务 我已经测试了WebService,并使用Postman发送了一个请求,它工作正常 下面是Web服务的代码 [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.Web.Script.Services.ScriptService] [System.C

我一直在尝试使用Angular调用Web服务

我已经测试了WebService,并使用Postman发送了一个请求,它工作正常

下面是Web服务的代码

[WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.Web.Script.Services.ScriptService]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Temperature : System.Web.Services.WebService
    {
        [WebMethod]
        public double Farenheit(double celsius)
        {
            return  (celsius * 9) / 5 + 32;
        }
        [WebMethod]
        public double Celsius(double fahrenheit)
        {
            return (fahrenheit - 32) * 5 / 9;
        }
    }
这是我的角度代码

const httpOptions = {
      headers: new HttpHeaders({
        'Content-Type':  'application/json',

      })
    };

this.http.post('https://localhost:44389/Temperature.asmx/Celsius', 50,  httpOptions)
    .subscribe(res => {
      console.log('Data: ' + res);

    })
该方法接受Int数据类型。我传递的是
50
整数。那么为什么我会收到这个错误呢。我不明白为什么

ExceptionType: "System.InvalidOperationException"
Message: "Cannot convert object of type 'System.Int32' to type 'System.Collections.Generic.IDictionary`2[System.String,System.Object]'"
StackTrace: "   at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
↵   at System.Web.Script.Serial
这是邮递员要求的截图

您需要通过以下考试:

{fahrenheit: 50}
而不是:

50
这是因为您现有的代码向上传递了一个数字,但没有指示它映射到哪个参数。通过明确提及
fahrenheit
,服务器端能够将
50
值映射到适当的方法参数