HttpWebRequest.ReadWriteTimeout 属性

本文介绍了如何通过HttpWebRequest中的ReadWriteTimeout属性来控制读写流的超时时间,并解释了其与Timeout属性的区别及应用场景。


获取或设置写入或读取流时的超时。 

属性值
在写入超时或读取超时之前的毫秒数。默认值为 300,000 毫秒(5 分钟)。 

备注

在写入由 GetRequestStream 方法返回的流时,或在读取由 GetResponseStream 方法返回的流时,会用到 ReadWriteTimeout 属性。

具体而言,ReadWriteTimeout 属性控制 Read 方法(用来读取由 GetResponseStream 方法返回的流)和 Write 方法(用来写入由 GetRequestStream 方法返回的流)的超时。

若要指定等待请求完成的时间量,请使用 Timeout 属性。

HttpWebRequest.Timeout属性 ttpWebRequest.ReadWriteTimeout 属性 两个都设置就没有问题了 

System.Net.WebException 未處理 HResult=-2146233079 Message=作業逾時 Source=System StackTrace: 於 System.Net.HttpWebRequest.GetResponse() 於 WindowsApplication1.Form1.CallWebAPIHttpClient(String urls, String send_methods) 於 E:\U232609\泰國廠\ashx文件應用客戶端\ashx文件應用客戶端\Form1.vb: 行 196 於 WindowsApplication1.Form1.Button4_Click(Object sender, EventArgs e) 於 E:\U232609\泰國廠\ashx文件應用客戶端\ashx文件應用客戶端\Form1.vb: 行 130 於 System.Windows.Forms.Control.OnClick(EventArgs e) 於 System.Windows.Forms.Button.OnClick(EventArgs e) 於 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 於 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 於 System.Windows.Forms.Control.WndProc(Message& m) 於 System.Windows.Forms.ButtonBase.WndProc(Message& m) 於 System.Windows.Forms.Button.WndProc(Message& m) 於 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 於 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 於 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 於 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) 於 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) 於 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) 於 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) 於 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() 於 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() 於 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) 於 WindowsApplication1.My.MyApplication.Main(String[] Args) 於 17d14f5c-a337-4978-8281-53493378c1071.vb: 行 81 於 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) 於 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 於 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 於 System.Threading.ThreadHelper.ThreadStart_Context(Object state) 於 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 於 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 於 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 於 System.Threading.ThreadHelper.ThreadStart() InnerException:
08-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值