File post problem - ASP.Net
I have to a web services method called uploadFile.the method getting a parameter as base64str and record as a file into the specified address it. But,I have a problem.That method doesn't allow to upload more than 350 KB file.Otherwise,I can upload less than 300 KB file e.g zip, jpg, txt. Also, When I attempt to upload more than 350 KB file,a process working continually on server.
Process:
Image Name : w3wp.exe, UserName : ASP.Net v4.0, CPU : 50, Description : IIS Worker Process
Sometimes server cpu goes to 100%
Code:
* encodedFile = Base64Str as format
string postString = string.Format("userName={0}&userVendor={1}&vendorKey={2}&base64FileStr={3}&guid={4}&fileName={5}", "kadi", "şifre", "key", encodedFile, guid, strFilename);
string localHttpPostUrl = userGatewayAddress + "uploadFile";
ASCIIEncoding encoding = new ASCIIEncoding();
Stream newStream = null;
HttpWebResponse response = null;
Stream streamResponse = null;
StreamReader streamRead = null;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(localHttpPostUrl);
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
byte[] buffer = Encoding.UTF8.GetBytes(postString);
request.ContentLength = buffer.Length;
newStream = request.GetRequestStream();
newStream.Write(buffer, 0, buffer.Length);
newStream.Close();
response = (HttpWebResponse)request.GetResponse();
streamResponse = response.GetResponseStream();
streamRead = new StreamReader(streamResponse);
Char[] readBuffer = new Char[256];
ret = string.Empty;
int totalCharCount = 0;
int count = streamRead.Read(readBuffer, 0, 256);
while (count > 0)
{
totalCharCount += count;
ret += new String(readBuffer);
开发者_开发知识库 count = streamRead.Read(readBuffer, 0, 256);
}
ret = ret.Substring(0, totalCharCount);
return ret;
}
catch (Exception x)
{
return x.Message;
}
<system.web>
<!-- 100 KB Max POST size -->
<httpRuntime maxRequestLength="100"/>
</system.web>
http://support.microsoft.com/kb/832878
精彩评论