hey, I have a web service here, with a few aspx pages too. I want it to
display the current web service URL.
now the first example I have found is
System.Net.Dns.Resolve(System.Net.Dns.GetHostName()).AddressList[0].ToString()
but this gets the local IP addres of the computer. if I were running this
computer on a server, would this IP address be static and be the one I'm
looking for??
another sample I have here merely asks whatismyip.com for the external
internet IP address
// Create a new WebClient instance.
WebClient webClient = new WebClient();
// Download the Web resource and save it into a data buffer.
byte[] myDataBuffer =
webClient.DownloadData("http://www.whatismyip.com/automation/n09230945.asp");
// Display the downloaded data.
string download = Encoding.ASCII.GetString(myDataBuffer);
this returns the web IP address. is this possibly the right IP addres if the
server was a static IP web server?
can someone help clear this confusion?
thanks.
John Saunders [MVP] - 21 Mar 2008 12:00 GMT
> hey, I have a web service here, with a few aspx pages too. I want it to
> display the current web service URL.
Are you sure that there _is_ such a thing? What if the web service is
running in a server farm? The same service could have multiple urls
associated with it. What if there is more than one virtual path leading to
the same service? What if there are multiple copies of the service running
on multiple web sites on the same machine?
You can try HttpContext.Current.Request.CurrentExecutionFilePath, and see if
that is what you want, in the scenarios you want it in.

Signature
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer