locked
c# .net iis7 uplad files with more than 1GB RRS feed

  • Question

  • Hello,

    I want to upload files with more than 1GB. I already change the maxAllowedContentLength="4294967295" to allow bigger files and the maxRequestLength="2147483647", but nothing seems to work. I already change the limits in IIS, but still, doesn't work. The max value that I was able to send was 40M.

    My code:

    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.IO;
    using System.Linq;
    using System.Security.Cryptography;
    using System.Web;
    using System.Web.Services;
    
    namespace Ctrldocphc
    {
        /// <summary>
        /// Summary description for index
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [System.ComponentModel.ToolboxItem(false)]
        // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
        // [System.Web.Script.Services.ScriptService]
        public class index : System.Web.Services.WebService
        {
    
            [WebMethod]
            public string HelloWorld()
            {
                return "Hello World";
            }
    
            [WebMethod]
            public string CopiarFicheiro2(string ficheiro, string nomeNovo, string destino)
            {
                if (!Directory.Exists(destino))
                {
                    Directory.CreateDirectory(@"" + destino);
                }
                byte[] byt = Convert.FromBase64String(ficheiro);
                File.WriteAllBytes(@"" + destino + nomeNovo, byt);
                return "true";
            }
    
            [WebMethod]
            public string CopiarFicheiro_20MB(string ficheiro, string nomeNovo, string destino)
            {
                if (!Directory.Exists(destino))
                {
                    Directory.CreateDirectory(@"" + destino);
                }
                byte[] docbinaryarray = Convert.FromBase64String(ficheiro);
              // string strdocPath = Path.Combine(@"" + destino, nomeNovo);
    
    
                FileStream objfilestream = new FileStream(@"" + destino+nomeNovo, FileMode.Create, FileAccess.ReadWrite);
                objfilestream.Write(docbinaryarray, 0, docbinaryarray.Length);
                objfilestream.Close();
    
               
    
                return "true";
            }
    
            [WebMethod]
            public string CopiarFicheiro(string ficheiro, string nomeNovo, string destino)
            {
                string _return = "true";
                if (!Directory.Exists(destino))
                {
                    Directory.CreateDirectory(@"" + destino);
                }
                byte[] docbinaryarray = Convert.FromBase64String(ficheiro);
               
    
    
                using (FileStream fs = new FileStream(
                    @"" + destino + nomeNovo,  // name of file
                    FileMode.Create,    // create or overwrite existing file
                    FileAccess.Write   // write-only access
                    ))
                {
                    for (int i = 0; i < docbinaryarray.Length; i++)
                    {
                        fs.WriteByte(docbinaryarray[i]);
                    }
    
    
                  
                }
    
               
                    return _return;
            }
    
    
    
    
        }
    
    
    }
    

    Any configuration to iis to allow me to send larger files ?

    Monday, April 29, 2019 5:43 PM

All replies

  • Hi AdrianoMaia2019.

    For IIS related questions, you should refer to the IIS.NET Forums.

    Bye.


    Luigi Bruno
    MCP, MOS, MTA, MCTS, MCSA, MCSE

    Monday, April 29, 2019 6:40 PM