SETTING THE IP OF CONNECTION C#

Tanuj Kumar

Total Post:134

Points:940
Posted by  Tanuj Kumar
C# 
C#
 1953  View(s)
Ratings:
Rate this:
I have a web browser in my application and I want to change the IP of the incoming connection that's about to load the page. How would I set the connection's IP address? I've done it before in Java but I have no idea on how to do it in C#.
  1. ezra heywood

    Post:145

    Points:1019
    Re: Setting the IP of connection C#

    Hi Tanuj,

    If you want to set the proxy address, you can do it on the WebRequest:

    using System;
    using System.IO;
    using System.Net;
    class Program
    {
        static void Main(string[] args)
        {
            WebRequest wr = WebRequest.Create("http://www.google.com");
            WebProxy proxy = new WebProxy("http://localhost:8888");
            wr.Proxy = proxy;
            StreamReader sr = new StreamReader(wr.GetResponse().GetResponseStream());
            Console.WriteLine(sr.ReadToEnd());
            Console.ReadLine();
        }
    }

      Modified On Apr-03-2018 06:18:47 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!