c# - Invalid URI: Invalid port specified when url has more than one colon -


I am using dnsdynamic.org so that my personal website hosted at my house can be talked about. My house IP will often change once a month. Dnsdynamic.org provide a web method call to update the IP.

  https: // username: password@www.dnsdynamic.org/api/? Hostname = techno.ns360.info and myip = 127.0.0.1   

When I call it through the browser it works correctly. When I try to call it via # c #, it throws the following exception. Invalid URI: invalid string specified on system.Uri.CreateThis (String Uri, Boolean dontEscape, UriKind UuriKind) on System.Net.WebRequest.Create (string request urstring) < / Pre>

Since the URL looks like a colon, System.uri tries to parse its password as an integer.

I tried to add a port after .OR

  https: // username: password@www.dnsdynamic.org: 443   

There is no luck with this.

Can anyone tell me how to solve this error?

I tried to escape when trying to escape Yuri and avoid the option, still not working.

  var ri = new Uri ("https: // username: password @ www.dnsdynamic.org/api/?hostname=techno.ns360.info&myip=127.0.0.1" target=12 );   

EDIT: It seems that the user name is causing the problem. My username is my email address and my email address is ending with * .com, so Yuri is trying to parse my password.

Still, no solution was found to overcome this issue. I can not change my username because dnsdyanmic.org uses the email address as the username.

To create Reqeust, you are using HttpWebRequest , in the URI Credentials should not be included (as you can tell, this is invalid).

Let's handle credentials instead of HttpWebRequest and pass it through them:

  // It is broken only for readability var uri = New URI ("https: //www.dnsdynamic org / api / hostname = techno.ns360.info" + "and mip = 127.0.0.1", true); Var cache = new credential cache (); Cash Add (Yuri, "Basic", New Network Credentials ("Username", "Password")); Var request = WebRequest.Create (uri); request. Credentials = Cache;    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -