如何在 F# 中设置 HttpResponseMessage.Content?
How can I set HttpResponseMessage.Content in F#?
据我了解,应该可以像这样设置响应消息的内容:
let responseMessage = new HttpResponseMessage(HttpStatusCode.OK)
responseMessage.Content = new StringContent("test")
但是,这样做时出现以下错误:
Parser Error: This expression was expected to have type HttpContent but here has type StringContent
我在测试项目中这样做是为了存根响应。它针对 .NET 4.5 和 FSharp Core 4.3.1.0
正如ildjarn所说,=
是相等比较,<-
是赋值。
let responseMessage = new HttpResponseMessage(HttpStatusCode.OK)
responseMessage.Content <- new StringContent("test")
据我了解,应该可以像这样设置响应消息的内容:
let responseMessage = new HttpResponseMessage(HttpStatusCode.OK)
responseMessage.Content = new StringContent("test")
但是,这样做时出现以下错误:
Parser Error: This expression was expected to have type HttpContent but here has type StringContent
我在测试项目中这样做是为了存根响应。它针对 .NET 4.5 和 FSharp Core 4.3.1.0
正如ildjarn所说,=
是相等比较,<-
是赋值。
let responseMessage = new HttpResponseMessage(HttpStatusCode.OK)
responseMessage.Content <- new StringContent("test")