WebClient.UploadString 方法的最大数据长度 [英] Maximum data length for WebClient.UploadString method

查看:44
本文介绍了WebClient.UploadString 方法的最大数据长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 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 字节,因为使用 ints (~2GB) 的内部转换/编码方法.只要 Encoding.GetBytes 可以处理它并且您有足够的 RAM,您就不太可能在此之前受到限制.

The only theoretical limit is Int32.MaxValue bytes because of the internal conversion/encoding methods working with ints (~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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆