.NET Remoting, ASP.NET Uploading and SQL Server Storage RRS feed

  • Question

  • Hello All!!!

    Any help, guidence and/or advise needed.  I have an application that allows our customers to upload documents of sizes up to 50MB to our site.  It uses a Webserver --> Application Server --> SQL Server.  Now, it works and this is the requirements set by my superiors.  The problem is lately i am getting the BinaryFormatter Version Incompatibility error when uploading a document. (NOTE: this is a .net 1.1 app). After some digging and using Wireshark to decifer what the real problem was I determined it was in a totally unrelated routine that sends an email notification.  That being said.   I am continually having problems with serialization on large file uploads and now sometimes with smaller files uploads. 

    What the perferred way to upload large files from the web into an internal database?  Right, now I am storing a temp file on the webserver then using remoting to move the file from the webserver to the database through an intermediary app server.

    Any guidence/examples/words of advice would be greatly appreciated and help with my arguments for upgrading the app and/or completely changing it.

    Thursday, April 2, 2009 5:20 PM


  • From the web app perspective you can use something like this to grab the upload (search web.config fixes to control the allowed size of the upload)

    public void UploadFile(HttpPostedFile File)
                string extension = Path.GetExtension(File.FileName).ToLower();
                string mimetype;
                byte[] uploadedImage = new byte[File.InputStream.Length];
                switch (extension)
                    case ".png":
                    case ".jpg":
                    case ".gif":
                        mimetype = File.ContentType;
                        _view.ShowMessage("We only accept .png, .jpg, and .gif!");
                if (File.ContentLength / 1000 < 1000)
                    File.InputStream.Read(uploadedImage, 0, uploadedImage.Length);
                    profile.Avatar = uploadedImage;
                    profile.AvatarMimeType = mimetype;
                    profile.UseGravatar = 0;
                    _view.ShowMessage("The file you uploaded is larger than the 1mb limit.  Please reduce the size of your file and try again.");

    In the above code the profile object is a LINQ to SQL object and the image is being stored in a VarBinary(MAX) field in a SQL 2k5 db.

    You shouldn't need an app server or temp files or any of that (assuming that your pipe is fast enough and you don't experience times outs).

    You my try writing an active x or java client program to package the file being sent or split up the file being sent to make your app more reliable and more efficient. 
    Andrew Siemer www.andrewsiemer.com blog.andrewsiemer.com www.socialnetworkingin.net
    Monday, April 6, 2009 9:01 PM