使用c#设置http referrer

时间:2011-10-24 14:29:15

标签: c# .net

我有以下C#代码为给定网址创建http请求,但我需要查看网页。是否可以创建Web请求以允许我控制http referrer值,同时还能够查看目标网页?现在,看起来这个应用程序正确设置了引荐来源,但我想在应用程序完成后在浏览器中看到http://localhost:8000

非常感谢,

class Program
{
    const string MyUrl = "http://localhost:8000";

    static void Main(string[] args)
    {
        var myHttpWebRequest = (HttpWebRequest)WebRequest.Create(MyUrl);

        myHttpWebRequest.Referer = args[0];

        var myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();

        var streamResponse = myHttpWebResponse.GetResponseStream();

        if (streamResponse != null) streamResponse.Close();

        myHttpWebResponse.Close();
        Console.WriteLine("Referer to the site is:{0}", myHttpWebRequest.Referer);
        Console.Write(Console.ReadLine());
    }
}

}

0 个答案:

没有答案