[Csharp]
/// <Summary>
/// Ajax cross-second-level domain proxy page
/// </Summary>
Public class AjaxCrossDomainProxy: IHttpHandler
{
Public void ProcessRequest (HttpContext context)
{
Context. Response. Cache. SetNoStore (); // no client Cache is required
Context. Response. ContentType = "text/plain ";
String url = context. Request ["url"];
HttpWebResponse response = null;
Stream stream = null;
Try www.2cto.com
{
Var request = (HttpWebRequest) WebRequest. Create (url );
Request. Headers. Add ("Cookie", context. Request. Headers ["Cookie"]); // transfer the cookie of the current second-level domain name to the past
Response = (HttpWebResponse) request. GetResponse ();
Stream = response. GetResponseStream ();
Var reader = new StreamReader (stream );
String result = reader. ReadToEnd ();
Context. Response. Write (result );
}
Finally
{
If (response! = Null) response. Close ();
If (stream! = Null) stream. Dispose ();
}
}
Public bool IsReusable
{
Get
{
Return false;
}
}
}