WebClient.UploadString 方法的最大数据长度 [英] Maximum data length for WebClient.UploadString method
问题描述
我的 asp.net mvc 应用程序中有以下代码 -
I have the following code in my asp.net mvc app -
string URI = "http://send.url.com/smsapi/sender.php";
string queryParameters= "a long query string";
string xmlResult = "";
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
xmlResult = wc.UploadString(URI, queryParameters);
}
我的问题是 queryParameters
可以用于 WebClient.UploadString
方法多长时间?
My question is how long queryParameters
can be for WebClient.UploadString
method?
推荐答案
WebClient
类对字符串的长度实施无限制.就它而言,它正在传输数据字节.
The WebClient
class enforces no limit on the length of a string. As far as it is concerned it is transmitting bytes of data.
唯一的理论限制是 Int32.MaxValue
字节,因为使用 int
s (~2GB) 的内部转换/编码方法.只要 Encoding.GetBytes
可以处理它并且您有足够的 RAM,您就不太可能在此之前受到限制.
The only theoretical limit is Int32.MaxValue
bytes because of the internal conversion/encoding methods working with int
s (~2GB). As long as Encoding.GetBytes
can handle it and you have sufficient RAM you are unlikely to be limited before that.
这篇关于WebClient.UploadString 方法的最大数据长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!