0

I have searched so many places but found no reasonable answer to my application requirement. i am developing C# WinForm application in visual Studio.

Q. On application start it should check if computer has internet connection or not, if there in internet connection it automatically disable it but keeping localarea network alive?

i have tried many codes but they just disables whole modem and localarea network goes offline, this way application is unable to access SQL Server database.

Q. If there is anyway to keep connection in local network and turn off internet while application in use, once application exits internet connection comes back on.

Bukhalifa
  • 13
  • 1
  • 8
  • Would you please add why your application needs to do this? If someone is asking a question like that, it raises some flags. Maybe it's just me ... – Fildor Sep 07 '17 at 07:46
  • 3
    `I have searched so many places but found no reasonable answer`. Sorry but you suck on search. :) [How to disable Internet connection without disabling the LAN/network](http://www.techsupportforum.com/forums/f31/solved-how-to-disable-internet-connection-without-disabling-the-lan-network-232894.html), [How can you change Network settings (IP Address, DNS, WINS, Host Name) with code in C#](https://stackoverflow.com/questions/209779/how-can-you-change-network-settings-ip-address-dns-wins-host-name-with-code) – Renatas M. Sep 07 '17 at 07:52

1 Answers1

-1

Remove the DNS Server and Default Gateway addresses, that will disable the Internet access and leave your local file/print sharing working.

information found here: Link

  • Mhm, do that. Then crash the app and it will stay like this. IT-Dptmt will grill your buttocks. – Fildor Sep 07 '17 at 07:48
  • @Fildor OP has it's own reasons to do so and maybe there is no IT-Department there. – Renatas M. Sep 07 '17 at 07:50
  • This is valid answer but you should add reference where you copied information from....and remove that "I would comment..." story lines. – Renatas M. Sep 07 '17 at 07:54
  • "have you tried turning your pc on and off again", sorry jokes aside. But Op never said anything about an it-department. But there is solutions for that aswell. – user3759748 Sep 07 '17 at 07:55
  • @Reniuz I agree, but we can only speculate about these things as long as they don't make a statement about their reasoning. However: An App with such behavior always raises some red flags on my side. As I said: Maybe it's just me, but I would like the OP to be aware of possible negative consequences / dangers of such functionality. _TL;DR:_ All I want to say is: please be careful! – Fildor Sep 07 '17 at 08:18