Note that there are some explanatory texts on larger screens.

plurals
  1. POIntercepting webpage requests through Wireless Hosted Network
    primarykey
    data
    text
    <p>Good Evening,</p> <p>I have created a Wireless Hosted Network on my Windows 8 Laptop, via the following 2 batch commands: "netsh wlan set hostednetwork mode=allow ssid=testing key=12345678" and "netsh wlan start hostednetwork"</p> <p>Afterwards, a device (Android-based mobile phone) is able to connect successfully to this Wireless Hosted Network hosted on my laptop. I've also created a HttpListener on port 1234 in C#, which the device can successfully access by using the built in web browser to access:</p> <pre><code>http://192.168.138.1:1234 </code></pre> <p><strong>However, how would the host (I.E. my laptop) intercept and redirect webpage requests? That is, how would a .NET program running on my laptop be notified when a device tries to access any webpage, say, google.com or facebook.com, and then redirect the device to another webpage by sending this webpage to it instead?</strong></p> <p>I have tried the following:</p> <pre><code>HttpListener listener = new HttpListener(); listener.Prefixes.Add("http://+:80/"); listener.Start(); Console.WriteLine("Started"); while (true) { var c = listener.GetContext(); Console.WriteLine("Connection"); string response = "&lt;HTML&gt;&lt;BODY&gt;My web page.&lt;br&gt;&lt;/BODY&gt;&lt;/HTML&gt;"; //Redirects device to this byte[] b = Encoding.UTF8.GetBytes(response); c.Response.ContentLength64 = b.Length; c.Response.OutputStream.Write(b, 0, b.Length); c.Response.OutputStream.Close(); } </code></pre> <p>However, the program running on my laptop does not pick up anything at all when I use the device to access any webpage (E.G. google.com). Sorry if I have asked a repeated question, I couldn't find it anywhere!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload