1

I'm working with C# and MVC3 and I'm trying to upload a text file that I know is not empty, but when I access the file (when debugging) via Request.Files["Cv"].ContentLength is 0.

How come this happens? I know the file is not empty, as it has some text strings there but I need to check that there..

Thanks a lot everybody in advance.

Best, Manuel

noloman
  • 11,411
  • 20
  • 82
  • 129
  • Are you sure that Request.Files["CV"] exists? Also could you show the code around this. – msarchet Jan 18 '12 at 16:02
  • 1
    Have you verified that the file is actually being sent to the server? I would recommend checking this first, typically I inspect the HTTP traffic between my browser and web app using fiddler. – Ken Henderson Jan 18 '12 at 16:03
  • @msarchet yes, I can see the name of the file that I'm trying to upload, the `ContentType` and the rest of attributes. – noloman Jan 18 '12 at 16:03
  • Please show your code. View and controller action. – Darin Dimitrov Jan 18 '12 at 16:04
  • I'm using two controllers for two parts of my web app that are using the same code for the uploading; I'm uploading the same file and it's working on one controller, but not in the other :) – noloman Jan 18 '12 at 16:08
  • @noloman, I didn't ask if it is working or not. I asked to see your code please. I asked an example that will allow me to reproduce your problem. Because I can point you to an answer illustrating that this works without any issue: http://stackoverflow.com/questions/5193842/file-upload-asp-net-mvc3-0/5193851#5193851. So apparently the problem is with your code. And without seeing your code I don't see how I can help you. – Darin Dimitrov Jan 18 '12 at 16:10
  • Please post header from Fiddler. – Pol Jan 18 '12 at 16:12

1 Answers1

-1

I figured the problem out by myself: it was a matter of initializing the model in the right place.. thanks everybody for your help!

noloman
  • 11,411
  • 20
  • 82
  • 129