c# page_unload firing together with after page_load
<p>So i want to delete some files when a user closes the browser.</p>

<p>I'm using the <code>page_unload</code> method shown below: </p>

<pre><code>   protected override void OnUnload(EventArgs e)
    {
        base.OnUnload(e);
        string[] uploadedFiles = Directory.GetFiles(Server.MapPath("~/testPdfIn"));
        foreach (string uploaded in uploadedFiles)
        {
            File.Delete(uploaded);
        }
    }
</code></pre>

<p>but the <code>page_unload</code> method will just fire right after the page load, deleting the files in folder without the user even closing the browser.</p>

<p>Is there a way to stop the <code>page_unload</code> from firing right after loading and only firing when user closes the browser?</p>
