You can try a few things, you will not specify which protocols you use or how your hosting, so I assume that it could be IIS7 and your use of soap. In the web serviceโs web.config file, you can add the following, which will increase the file size allowed for transmission without 404 error:
<system.web> <httpRuntime executionTimeout="999999" maxRequestLength="2097151" /> ... </system.web>
The second thing you might want to do in the web.config file of a web service is to allow large file transfers:
<system.webServer> <security> <requestFiltering> <requestLimits maxAllowedContentLength="2000000000" /> </requestFiltering> </security> </system.webServer>
Another possibility:
<location path="Copy.asmx"> <system.webServer> <security> <requestFiltering> <requestLimits maxAllowedContentLength="104857600"/> </requestFiltering> </security> </system.webServer> </location>
The main problem with sending byte [] over web services is that they fall into the SOAP body, which receives the encoding as the base line 64. Such encoding files increase the file size by two-thirds in the body of the soap (that is, a file of size 6 MB becomes a 9 MB file over the wire).
Another possibility is to โsplit upโ into dividing your data into smaller segments before transferring, which may be all you need. ChunkSize (installed at 500KB) can be a key factor in improving download performance based on factors such as network speed, server resources, etc.
/// <summary> /// Chunk the file and upload /// </summary> /// <param name="filename"></param> private void UploadVideo(string filename) { #region Vars const int chunkSize = 512000; byte[] bytes = null; int startIndex, endIndex, length, totalChunks; WS.UploadRequest objRequest = new WS.UploadRequest(); #endregion try { if (File.Exists(filename)) { using (WS.UploadService objService = new WS.UploadService()) { using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read)) { //// Calculate total chunks to be sent to service totalChunks = (int)Math.Ceiling((double)fs.Length / chunkSize); //// Set up Upload request object objRequest.FileName = filename; objRequest.FileSize = fs.Length; for (int i = 0; i < totalChunks; i++) { startIndex = i * chunkSize; endIndex = (int)(startIndex + chunkSize > fs.Length ? fs.Length : startIndex + chunkSize); length = endIndex - startIndex; bytes = new byte[length]; //// Read bytes from file, and send upload request fs.Read(bytes, 0, bytes.Length); objRequest.FileBytes = bytes; objService.UploadVideo(objRequest); } } } } } catch (Exception ex) { MessageBox.Show(string.Format("Error- {0}", ex.Message)); }