Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid Uri: The Uri scheme is not valid

Tags:

c#

uri

I am trying to make a connection via HttpWebRequest. I am reading url links from a text file. However, I am getting 'System.UriFormatException' error.

I have tried to add http:// in front of the url links in my text file. But the result is the same.

What can be the solution?

like image 495
Val Nolav Avatar asked Dec 22 '22 08:12

Val Nolav


2 Answers

If the error only occurs when reading the values from a file, but not when assigned directly to a string variable, then I'm guessing that there are extra characters being read (quotes, escaped characters, carriage-return/line feeds, etc).

Try reading the first value into a string, and then comparing that to what you expect in the explicit string value. Any differences should be obvious after that.

like image 63
Daniel Becroft Avatar answered Dec 24 '22 01:12

Daniel Becroft


Without seeing code it's impossible to tell what you're trying to do. But you can start by looking at the Message property of the UriFormatException class. Message is a string that explains the reason for the exception.

like image 33
Anson Avatar answered Dec 24 '22 02:12

Anson