I have one issue that i want to ping URL from code behind (EXE project) by which i can know environment of Azure application on which my EXE is running.
string dep = RoleEnvironment.DeploymentId.ToString();
WebRequest req = WebRequest.Create("http://" + dep + ".cloudapp.net");
HttpWebResponse rep= null;
try
{
rep = (HttpWebResponse)req.GetResponse();
}
catch (Exception)
{
//if environment is production then this URL will not work
//do some functionality
}
So by above code i would like to do some functionality when it will production environment ,above logic is works well but would like to get some perfect solution like ping command that if URL exist then return true otherwise false.
Please suggest me some good logic here
Thanks in advance.