I had make an reverse proxy using IHttpAsyncHandler class that listen on the iis request and according to the incoming url path i send a request to another site
public class ReverseProxy : IHttpAsyncHandler { public bool IsReusable { get { return true; } } public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { _context = context; //some code remoteUrl = GetRemoteUrl(context, ref remoteUrl); _request = (HttpWebRequest)WebRequest.Create(remoteUrl); _helper.CopyHeadersRequest(context.Request, _request, ref _newUri); // Copy POST Data if (context.Request.RequestType == "POST") { _request.ContentLength = context.Request.ContentLength; _request.ContentType = "application/x-www-form-urlencoded"; _helper.CopyStream(context.Request.InputStream, _request.GetRequestStream()); } return _request.BeginGetResponse(cb, extraData); } private string GetRemoteUrl(HttpContext context, ref string remoteUrl) { //get the new site url } public void EndProcessRequest(IAsyncResult result) { HttpWebResponse response; try { response = (HttpWebResponse)_request.EndGetResponse(result); _helper.CopyHeadersResponce(response, _context, ref _segments); //some other code } catch (System.Net.WebException we) { Return404(_context); return; } }
the problem is when i call an remote asp website the response come back without the session cookies (ASP.NET_SessionId). and this remote website lose the session data. What can be the problem ?