Problem in ASP.Net File Upload Application

G

Guest

The basic purpose of the site is for authenticated users to post event
listings, which often include photographs. The user is faced with a page
where they can insert all of the information about the event in a typical
form with textboxes, drop down lists, etc. On this page there are also 4
file upload controls where the user can select 0 to 4 images on their file
system for inclusion in the event listing. On submit, the images (if any)
are uploaded to the server and named based on the user id and picture number,
eg. 123456_01.jpg, 123456_02.jpg, etc. The user is shown a preview of the
event with the images. On submit the event is inserted in the database with
a return value of the pk or EventID number. This number is used to rename
the images, eg. 123456_01.jpg becomes 9876_01.jpg, 123456_02.jpg becomes
9876_02.jpg.

This generally works very well. The image upload directory is directly
under the root of the website and has full control for ASP.Net, Network
Service, Everyone. this is IIS6 on Server 2003. However, a very small
portion of our users report that when they go to upload more than one event,
when the preview shows up for the second event, the photos from the first
event show up. We also get reports that if they "shut down the computer and
reopen it" between each listing it works ok. This is not acceptable since we
get paid by the listing. I have requested of some users that they clear
their browser cache, delete all temporary files and cookies, and try again
but these users report that it still occurs.

Is this a file upload permissions problem, or is it somehow that images are
being cached somewhere since the name of the images on the preview page is
the same (username + image number + .jpg)?

If this is a caching problem is there some way to make sure that images are
not cached anywhere? What tags, if any can be used on the pages, or settings
in iis?
 
G

Guest

Would like help on this issue as the 48 hr response time has elapsed, so let
me further elaborate.

Because the image is always temporarily saved as the userId + extension then
for every event the image will have the same name as the previous event and
the one before that etc., but only when the event is saved is and eventId
generated, and so the image is then renamed to eventId + extension. User
then goes to add another event, uploads his description and pic, and then
there is the previous picture and not the one he just uploaded, preventing
the user from uploading any more events, and thus preventing us from earning
any money, causing my boss to bug me about fixing it, causing me to post here
where we are supposedly getting a response from Microsoft within 48 hours.

When this first started occuring I assumed it to be file permission problem
on the new server, but I went ahead and gave the Network Service account full
control over the imageUpload directory, which is under the website. Does
anyone have any opinions about this? Should Network Service have such
privilege, is having the directory under the website causing IIS to become
adversely involved in this somehow?

Since I thought it also might be that file upload control itseltf or the
resizing events were not releasing their references or holds or whatever on
these files, I went back and wrote a boatload of things like

Finally
rawBitmap = Nothing
resizedBitmap = Nothing
postedFile = Nothing

But then since every file gets renamed to the eventId + extension...Its
probably superfluous?

Then I think, what else could it be? It has te be an image stuck downstream
in a client or proxy cache? Isnt that what a cache does, prevents grabbing a
new version of something, and since the old image was username+extension and
the new image is also called username+extension is ist simply not getting the
latest image and so our clients look at the event preview and even though
their image was uploaded (?) they see the old image and freak out?

If this is the case, a MS engineer would probably say something like, ah ha
see, not a bug or problem in VS, but a problem somewhere else, case closed.
And yet I wrote an application that doesn't work for some users in some
situations and I need to fix it. If this is indeed what is happening (I have
no idea really) is there a better way to engineer the application such that
this will not happen to any users?
 
K

Kevin Spencer

Add a QueryString with a random number to the image URL (e.g.
"/images/12345.jpg?n=520"). This will fool the browser into thinking that it
is not the same image, and it will request it from the server.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
G

Guest

Thank you Kevin, this works precisely as described, very low overhead simply
generating a random number. Thanks for your help.

We are not happy that this problem exists, however. We set up caching
wherever we need it and we do not expect anything to be cached elsewhere.

We instruct our clients to change their browser settings to check for a new
version of the page with every request but that setting does not affect
images, i presume.

What about an application that generates images using system.drawing and the
like and it is always returned the same way as in an aspx

<img src="captcha.aspx">

There needs to be a meta tag for this and browsers including and especially
Internet Explorer need to respect the tag.

Just my two cents while I have a soapbox.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top