日期:2014-05-18 浏览次数:20473 次
void Application_BeginRequest(Object sender, EventArgs e) { //这里把你的请求转发到站点B }
------解决方案--------------------
void Application_BeginRequest(Object sender, EventArgs e) { HttpApplication application = sender as HttpApplication; HttpRequest request = application.Request; string domain = "http://www.b.com"; string url = domain + request.Url.AbsolutePath + request.Url.Query; System.Net.HttpWebRequest webRequest = System.Net.WebRequest.Create(url) as System.Net.HttpWebRequest; if (request.HttpMethod == "GET") { //模拟个包 webRequest.Accept = "*/*"; webRequest.UserAgent = request.UserAgent; foreach(string head in request.Headers) webRequest.Headers.Add(head,request.Headers[head]); //还有其它的也加进去 } else if (request.HttpMethod == "POST") { //同理 } }