0

I have ASHX where user upload product image and i save uploaded file name in session["up_pro_image"]. On submit i read session value and make manipulation with file. But what if he have opened two pages and add product on both one, ill lose one file name from session. How to solve this?

Novkovski Stevo Bato
  • 1,013
  • 1
  • 23
  • 56

1 Answers1

0

Instead of saving it to the Session, you could write the events out to a database. Each file could have a flag on it called "IsProcessed". Your code could then query the db for all unprocessed files, process them, then set the flag back in the database.

mgnoonan
  • 7,060
  • 5
  • 24
  • 27
  • From my view, that`s almost the same. If he have opened two pages, press upload ill receive two files, but i don't know which file is for switch page (page as browser tabs). – Novkovski Stevo Bato Apr 05 '12 at 20:59
  • Almost the same, except you haven't lost any data points! Can't you adjust your application so that it doesn't care which tab submits the files, as long as they are in the same session? – mgnoonan Apr 05 '12 at 21:18
  • Im not sure if you got my point, but now ill explain more. Lets say you are logged with mine user and i`m also logged with mine user. Lets say you click "AddProduct.aspx" and also i click that page. Now you upload file but i also upload file. When you click save, whitch file is for you? I know this can be done by saving ASHX response to hidden field and then check if that file with that GUID exists etc... but any more secure way? – Novkovski Stevo Bato Apr 05 '12 at 22:01
  • Setting aside the security issue of logging in two users with the same credentials, adding a GUID identifier for each file upload session sounds like a good answer. Your original question mentioned two tabs, not two users, but this solution could fix both use cases. – mgnoonan Apr 05 '12 at 22:10