无法在异步中的httpresponsemessage中返回输出

发布于 2025-01-29 17:38:58 字数 712 浏览 1 评论 0原文

我正在努力阅读Adapter.postasync调用的输出。我期望它在我的响应对象中的httpresponsemessage类型中。

当我更改 dim响应为任务 dim响应作为任务(httpresponsemessage的任务)我会遇到错误,例如将隐式转换从任务转换为任务(OF)

这是代码i 具有到目前为止的调用方法

VB中

Dim response As Task = 
adapter.PostAsync("api/rules",modelObject)

在c#适配器类中的

public Task PostAsync<TResult>(string end, TResult postObject)
{
    // In this method I am calling api and  returns output as Task<httpresponsemessage>
    return httpClient.PostAsync(end, new stringcontent(jsonConvert.SerializeObject(postObject, json settings), encoding.UTF8, "application/json"));
}

I am struggling to read output from my adapter.PostAsync call. I am expecting it in a httpresponsemessage type in my response object.

When I change Dim response As Task to Dim response As Task(Of httpresponsemessage) I am getting error like disallows implicit conversion from task to task(of )

This is the code I have so far

Calling method which is in VB

Dim response As Task = 
adapter.PostAsync("api/rules",modelObject)

Called method which is in c# adapter class

public Task PostAsync<TResult>(string end, TResult postObject)
{
    // In this method I am calling api and  returns output as Task<httpresponsemessage>
    return httpClient.PostAsync(end, new stringcontent(jsonConvert.SerializeObject(postObject, json settings), encoding.UTF8, "application/json"));
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文