title: Make HTTPHandler (ashx) to place session cookie in ASP.NET
body: <p>How can I make a HTTPHandler in an ashx file PLACE a SessionCookie managed by ASP.NET? It seems, that the call of an ashx-File does not place a cookie, so no session can be maintained.</p>
  
  <p>Background: I am about to write HTTP based web service wrapper. Different clients call the URL I provide them with the given parameters. I check the credentials, call the 3rd party web service and deliver the changed result back to the client. The 3rd party web service provider demands by contract a SessionID for every different client calling.</p>
  
  <p>Solution: An HTTPHandler seems to be the best choice. So I created a Web Site Project. Unfortunately a direct call of a ashx-File seems not to add a session cookie to the response, so a new SessionID is being created for every call from the same client.</p>
  
  <p>I did the following relevant:</p>
  
  <ul>
  <li>Implemented markup interfaces IRequiresSessionState or/and
  IReadOnlySessionState</li>
  <li>Added <code>&lt;sessionState mode="InProc" cookieless="false" timeout="20" /&gt;</code>
  to the web.config</li>
  <li>Save something in the session state in the Global.asax File in the
  Session_Start-Method HttpContext.Current.Session("init") = 0</li>
  </ul>
  
  <p>Different attempts which work, but should be avoided:</p>
  
  <ul>
  <li>Before calling the ashx-File a call of the Default.aspx File places a session cookie, so the session is being maintained.</li>
  <li>Implement an “own” Session with a database and a timestamp.</li>
  </ul>
  
  <p>Version: IIS 6.0</p>