Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
文件发布问题-ASP.Net_Asp.net - Fatal编程技术网

文件发布问题-ASP.Net

文件发布问题-ASP.Net,asp.net,Asp.net,我必须创建一个名为uploadFile的web服务方法。该方法获取一个参数base64str并将其记录为指定地址的文件。 但是,我有一个问题。这种方法不允许上传超过350KB的文件。否则,我可以上传少于300KB的文件,例如zip、jpg、txt。也, 当我试图上传超过350KB的文件时,这个过程会在服务器上持续工作 过程: Image Name : w3wp.exe, UserName : ASP.Net v4.0, CPU : 50, Description : IIS Worker Pro

我必须创建一个名为uploadFile的web服务方法。该方法获取一个参数base64str并将其记录为指定地址的文件。 但是,我有一个问题。这种方法不允许上传超过350KB的文件。否则,我可以上传少于300KB的文件,例如zip、jpg、txt。也, 当我试图上传超过350KB的文件时,这个过程会在服务器上持续工作

过程:

Image Name : w3wp.exe, UserName : ASP.Net v4.0, CPU : 50, Description : IIS Worker Process
有时服务器cpu达到100%

代码:


  * 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>