Calling Server.Execute within a CacheItemRemovedCallback
<p>I'm trying to design a system where a user will get a confirmation email after their session has ended summerizing the changes they've made during that session.</p>

<p>Because a user can exit my system by just closing the broswer window, I can't just tie code into the "Logout" click.</p>

<p>My idea was to write a user specific token in the HttpContext.Current.Cache upon login. There would an 20 minute expiration and a callback method. I would "touch" the cache entry on every page hit by that user. Once the user has been inactive for 20 minutes, the callback method would be called, and I can send the email from there.</p>

<p>Here is simplified version of my code for generating and sending the email:</p>

<pre><code>        MailMessage msg = new MailMessage();


        msg.From = new MailAddress("foo@bar.com""foo bar");
        msg.To.Add("user@domain.com");
        msg.IsBodyHtml = true;

        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);

         HttpContext.Current.Server.Execute("Confirmation.aspx?USERID=220", htw,false);

         msg.Body = sw.ToString();

         SmtpClient Mailer = new SmtpClient();
         Mailer.Host = ConfigurationManager.AppSettings["SMTPServer"];
         Mailer.Send(msg);
</code></pre>

<p>The problem I'm having is HttpContext.Current is null when called within the cache callback.</p>

<p>Is there anyway around this?</p>
