I am trying to update my ip address on no-ip.com using the call they specify as per their page here http://www.noip.com/integrate/request
So far I tried
Dim webAddress As String = "http://username:password@dynupdate.no-ip.com/nic/update?hostname=mytest.testdomain.com&myip=1.2.3.4"
Process.Start(webAddress)
This gives error Additional information: The system cannot find the file specified
I tried this
Dim req As System.Net.WebRequest = System.Net.WebRequest.Create("http://username:password@dynupdate.no-ip.com/nic/update?hostname=mytest.testdomain.com&myip=1.2.3.4")
Dim resp As System.Net.WebResponse = req.GetResponse
Str = resp.GetResponseStream
It gives error Additional information: Invalid URI: Invalid port specified.
And also tried using a WebBrowser with
WebBrowser1.navigate("http://username:password@dynupdate.no-ip.com/nic/update?hostname=mytest.testdomain.com&myip=1.2.3.4")
It give error Additional information: Value does not fall within the expected range.
I think it might be related to these controls don't like how is the link is formated
BTW, I don't want to use no-ip own client ip updater, and of course I changed the details on the link :) When I copy and paste the link in Chrome it works fine and changes the ip as expected
Update This works fine now
Dim username As String = HttpUtility.UrlEncode("XXX@XXX.XXX")
Dim password As String = HttpUtility.UrlEncode("XXX")
Dim query As String = String.Format("http://{0}:{1}@dynupdate.no-ip.com/nic/update?hostname=XXXXXX.ddns.net&myip=" & TextBox2.Text, username, password)
Process.Start(query)
But ideally I would like to handle the request and the response in code without opening a browse (I only tried this to check why I am getting an error, but it is not the ideal solution)
When I try this
WebBrowser1.Navigate(query)
It works fine, and it is good for now, but still getting error when using this code which I would love to use.
Dim req As System.Net.WebRequest = System.Net.WebRequest.Create(query)
Dim resp As System.Net.WebResponse = req.GetResponse
Str = resp.GetResponseStream
This time I am getting error 401 Unauthorised
The url example that you shown works perfect.
Probablly what happens is that in your real code you're setting an username or password that contains blank space(s) or illegal chars, you need to escape/encode them.
You could use the System.Web.HttpUtility.UrlEncode function:
If characters such as blanks and punctuation are passed in an HTTP stream without encoding, they might be misinterpreted at the receiving end. URL encoding converts characters that are not allowed in a URL into character-entity equivalents
Then:
Dim username As String = HttpUtility.UrlEncode("username")
Dim password As String = HttpUtility.UrlEncode("password")
Dim query As String =
String.Format("http://{0}:{1}@dynupdate.no-ip.com/nic/update?hostname=mytest.testdomain.com&myip=1.2.3.4/", username, password)
Process.Start(query)
Do the same for each value, if any, that could contains illegal chars like for example the value you pass to the hostname
parameter.
Also for more safety put a /
ad the end of the address.