I have created a custom control which uploaded files to the server . These uploaded files list that is the name of the file and the file path i save in a session and the files i save to a temp directory .
Now, I want to delete these files as well as clear the session when this control is no longer used .How do i find whether the control is no longer used in the page . I should be doing this from the Custom control and not from the Page ??
Thanks in advance.
If you’re basically wanting to cleanup the session and temp directory, the solution I can think of would be like so:
1) On submit of your form, if successful, after processing that stuff, clear the temp directory of those files and the session variable.
2) If you ever find yourself attempting to write to the session variable when it is already set, delete any files found from the variable and then set it.
3) If the user never submits, closes the browser, etc, then add code to your Global.asax’s Session_End method, and cleanup there.