简体   繁体   English

HttpWebRequest .Net核心设置超时

[英]HttpWebRequest .Net Core set Timeout

I am trying to set the Timeout on an HttpWebRequest and it seems that it is not possible in .Net Core. 我试图在HttpWebRequest上设置超时,似乎在.Net Core中是不可能的。 The property 'Timeout' is no longer there. 物业'超时'不再存在。

Thanks 谢谢

I am trying to set the Timeout on an HttpWebRequest and it seems that it is not possible in .Net Core. 我试图在HttpWebRequest上设置超时,似乎在.Net Core中是不可能的。

It is possible in .NET Core if you are using .NET Core 2.0. 如果您使用的是.NET Core 2.0,则可以在.NET Core中使用。 You can see the support for the Timeout property here . 您可以在此处查看对Timeout属性的支持

在此输入图像描述

If you can, use the System.Net.Http.HttpClient instead, because... 如果可以,请改用System.Net.Http.HttpClient因为......

In general, for better app performance and features, we recommend developers move away from HttpWebRequest and adopt HttpClient API surface. 通常,为了获得更好的应用程序性能和功能,我们建议开发人员远离HttpWebRequest并采用HttpClient API表面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM