做一个项目asp.net项目.客户端向服务器post数据.如果数据比较少的话正常,但是一旦太大,就接收不到
我监视Request.InputStream发觉length=0;但是发觉Headers
Headers {Transfer-Encoding=chunked&Host=*******&User-Agent=Profile%2fMIDP-1.0+Configuration%2fCLDC-1.0%2cUNTRUSTED%2f1.0}System.Collections.Specialized.NameValueCollection {System.Web.HttpHeaderCollection}
请问asp.net 如何接收Transfer-Encoding=chunked的数据
我监视Request.InputStream发觉length=0;但是发觉Headers
Headers {Transfer-Encoding=chunked&Host=*******&User-Agent=Profile%2fMIDP-1.0+Configuration%2fCLDC-1.0%2cUNTRUSTED%2f1.0}System.Collections.Specialized.NameValueCollection {System.Web.HttpHeaderCollection}
请问asp.net 如何接收Transfer-Encoding=chunked的数据
http://bbs.hidotnet.com/29447/ShowPost.aspx
http://www.thescripts.com/forum/thread528079.html如果有简洁(出现该问题的最少代码)的代码,我可以调试一下,
我不知道怎么上传,我上传到这个地址上了。麻烦你帮我看一下.
protected void Page_Load(object sender, EventArgs e)
{
StreamWriter sr = new StreamWriter(Server.MapPath("debug.txt"), true);
BinaryWriter binWriter = new BinaryWriter(File.Open(Server.MapPath("1.mp3"), FileMode.Create));
try
{
Stream baseStream = this.Request.InputStream;
baseStream.Position = 0;
byte[] by = new byte[baseStream.Length]; baseStream.Read(by, 0, by.Length);
binWriter.Write(by);
long streamLength = baseStream.Length;
sr.WriteLine(streamLength.ToString());
}
catch (Exception ex)
{
sr.WriteLine(ex.Message);
}
finally
{
binWriter.Close();
binWriter = null;
sr.Close();
sr = null;
}}
上传
// 所要上传的文件路径
string path = txtFileData.Text.Trim();// 检查文件是否存在
if (!File.Exists(path))
{
MessageBox.Show("{0} does not exist!", path);
return;
}String uploadUrl = "http://localhost/b/default.aspx";HttpWebRequest httpRequest = (HttpWebRequest)HttpWebRequest.Create(uploadUrl);
httpRequest.Method = "POST";
//httpRequest.ContentType = "multipart/form-data";
httpRequest.AllowWriteStreamBuffering = false;
httpRequest.ProtocolVersion = HttpVersion.Version11;
httpRequest.SendChunked = true;
httpRequest.KeepAlive = false;
// httpRequest.ContentLength = bytes.Length;
// httpRequest.Headers.Add("Accept-Encoding: gzip, deflate");
httpRequest.Credentials = System.Net.CredentialCache.DefaultCredentials;
httpRequest.Timeout = 6000000;// 读文件流
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
try
{
Stream datastream = httpRequest.GetRequestStream();
byte[] fileBytes2 = new byte[fs.Length];
fs.Read(fileBytes2, 0, Convert.ToInt32(fs.Length));
txtResponse.Text = "\r\n正在上传 ";
Application.DoEvents();
datastream.Write(fileBytes2, 0, fileBytes2.Length);
datastream.Flush();
fs.Close();
datastream.Close();
}catch (ProtocolViolationException pve)
{ MessageBox.Show(pve.ToString());}txtResponse.Text = "\r\nok ";