Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact
A1VBCode Forums
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      

Home » .NET Programming (VB 2010 or earlier) » C# » check internet connection not internal...


check internet connection not internal...Expand / Collapse
Author
Message
Posted 3/23/2011 10:28:01 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 7/6/2011 3:55:16 AM
Posts: 10, Visits: 17
i am making an application that must check before running the internet connection

i am using this code

try
{

req = (HttpWebRequest)WebRequest.Create("http://www.1aeg.net");
resp = (HttpWebResponse)req.GetResponse();

if (resp.StatusCode.ToString().Equals("OK"))
{
connected_check = "1";
}
else
{
connected_check = "2";
}
}
catch (Exception exc)
{
connected_check = "2";
}




when i logged out from the server the internet connection will be disabled but the internal network in the office is still connected.



when i logged off or i did not enters the user name and password the internet access is not available but the internal network is available through the server.


how i can detect if the internet access is available regardless the internal network connection in the office????
Post #30212
Posted 3/7/2012 6:52:47 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 3/20/2012 9:59:13 PM
Posts: 7, Visits: 5
The default value for HttpResponse.StatusCode is 200 if its successfully established, I've never seem the ('OK') method u're using.

Anyway, Try this

protected void Page_Load(object sender, EventArgs e)
{
if (Response.StatusCode != 200)
{
Response.Write("Couldn't connect to the internet");
}
}

Regards.

Amr Mohallel
University of Sunderland
Faculty of Applied Sciences - Applied Business Computing
Post #31267
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Admin, Mod, Mark, Keithuk

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 2:09am