If HasFile is true, why is PostedFile "sometimes" == null in my tests?
That is, if I resubmit the form with the same data it's not null, and may be
repeatedly not null. But then it will occasionally be null again, for one
or two submits. It seems to be random.
What's going on here?
This is using ASP.net 2.0 SP 1.
Gary
private FileUpload FileUp;
FileUp = (FileUpload)Pnl.FindControl("FileUp");
if (!FileUp.HasFile)
{
if (FileUp.PostedFile == null) throw new
NullReferenceException("PostedFile is Null");
if (FileUp.PostedFile.ContentLength == 0)
{
MJOStaff.SetMsg("The file is either missing or empty",
MJOStaff.msgType.Warning);
return;
}
}
I finally found my problem.
ASP was not setting the form encoding, even though there was an asp upload
control on the page.
What made this a bit hard to track down was that it only intermittently
failed.
I explicitly set the encoding and now it seems to work all of the time, like
it should.
Gary
Thanks a bunch!
Gary Wardell wrote:
Hi,I finally found my problem.
26-Jul-08
Hi,
Gary
Previous Posts In This Thread:
On Wednesday, July 23, 2008 6:28 AM
Gary Wardell wrote:
FileUp.PostedFile == null
Hi,
Gary
On Saturday, July 26, 2008 3:16 PM
Gary Wardell wrote:
Hi,I finally found my problem.
Hi,
Gary
EggHeadCafe - Software Developer Portal of Choice
11 Ways to use JavaScript efficiently
http://www.eggheadcafe.com/tutorials/aspnet/60a4a785-5349-43ba-bc76-d98c3ffbc098/11-ways-to-use-javascript.aspx