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; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)