httpfilecollection

Invalid Cast Exception in HttpFileCollection

Hi Everyone, I have an extension method below, but when I run this, the foreach gives me InvalidCastException and it says * Unable to cast object of type 'System.String' to type 'System.Web.HttpPostedFile'. Code : public static List<Attachment> GetFiles(this HttpFileCollection collection) { if (collection.Count > ...

Calculate total content length of HttpFileCollection using Lambda expressions

My code has something like this: HttpFileCollection files Instead of looping through each file and adding up the file.ContentLength to get the total length of all content e.g. int totalLength = 0; for (int i = 0; i < files.Count; i++) { totalLength += files[i].ContentLength; } Is there a ...

Asp with vb.net codebehind, httpfilecollection loses data

I have an html input that i use to upload files. Now on my page when I try to authenticate a user first, and hide the div that the controls are in for my file uploads, the collection is empty. When I dont use runat = "server", it works as expected. Not sure how to get around this. Code: Here is what works...but without hiding... not wha...

Why doesnt doesnt HTML input of type file not work with Ajax update panel

I have a input of type file and when i try to do a Request.files when the input is wrapped in an update panel...it always returns an empty httpfilecollection. Why??? This is the codebehind: (At HttpContext.Current.Request.Files...its always 0 for the count.) Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.Event...

Null reference check required to enumerate a collection inside a reflected assembly?

I'm running into a very strange behavior in C#/.NET 3.5... I am writing a class which hooks into upload pipeline of a content management system. The CMS executes this hook via reflection. For some unknown reason the following code fails by throws a NullRef ("Files" is an HttpFileCollection). foreach (var fileKey in args.Files.AllKeys...