title: Access TempData within custom middleware
body: <p>I have custom middleware that provides global error handling. If an exception is caught it should log the details with a reference number. I then want to redirect the user to an error page and only show the reference number. My research shows that TempData should be ideal for this but it only seems to be accessible from within a controller context. I tried adding the reference number to <code>HttpContext.Items["ReferenceNumber"] = Guid.NewGuid();</code>
  But this value is lost through the redirect.</p>
  
  <p>How can middleware pass information through a redirect? Do I just have to put the number in a querystring?</p>