vb.net - Getting External IP -


i'm trying external ip of user, can save user file. can't find way it. i've tried doing:

private function getexternalip() net.ipaddress     using wc new net.webclient         return net.ipaddress.parse(encoding.ascii.getstring(wc.downloaddata("http://whatismyip.com/automation/n09230945.asp")))     end using end function 

but keep getting formatexception saying "ip invalid"

here code, may want add check ensure not run often:

 private shared function getexternalip() string      dim response string = string.empty      try          dim mywebclient new system.net.webclient         dim whatismyip string = "http://automation.whatismyip.com/n09230945.asp"         dim file new system.io.streamreader(mywebclient.openread(whatismyip))          response = file.readtoend()         file.close()         file.dispose()         mywebclient.dispose()      catch ex exception         response = "could not confirm external ip address" & vbcrlf & ex.message.tostring     end try      return response  end function 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -