RESTSHARP中的“ getAsync”和“ executeGetAsync”有什么区别?
方法retclient.getAsync
和RESTCLIENT.EXECUTEGETASYNC
之间有什么区别?我什么时候应该使用一个或另一个?
先感谢您。
What is the difference between the methods RestClient.GetAsync
and RestClient.ExecuteGetAsync
? When should I use one or the other?
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果服务器返回错误,则GetAsync将引发异常,因为它不是RESTCLIENT接口的一部分,并且返回
task< int>
即无法设置和响应状态代码。如果服务器返回错误,则
executeGetAsync将不会引发异常,因为它的返回类型是restresponse,并且它具有响应率属性来设置错误。
有关更多信息:
<
GetAsync will throw an exception if the server returns an error because it is not part of RestClient interface and return
Task<int>
i.e. there is no way to set and response status code.while
ExecuteGetAsync will not throw an exception if the server return an error because it's return type is RestResponse and it has ResponseStatus property to set an error.
For more information:
https://restsharp.dev/error-handling.html