Question about using : in URL

  • Thread starter Thread starter Anthony P.
  • Start date Start date
A

Anthony P.

Hello Everyone,

I'm using an URI object and I need to pass the url as follows:

http://ausername:[email protected]

The problem is that when VB.NET encounters the colon in the URL it
thinks it's a port and can't parse it. Is there a better way to pass
these credentials or, if not, how can I get around this?

Thanks!
 
Hello Everyone,

I'm using an URI object and I need to pass the url as follows:

http://ausername:[email protected]

The problem is that when VB.NET encounters the colon in the URL it
thinks it's a port and can't parse it. Is there a better way to pass
these credentials or, if not, how can I get around this?

Thanks!

Hi,
You can try to initialize a NetworkCredential object and pass
username, password and domain in its constructor as
follows:

Imports System.Net
Dim nc As New NetworkCredential("user","pass","domain")

http://msdn.microsoft.com/en-us/library/system.net.networkcredential.aspx
http://msdn.microsoft.com/en-us/library/system.net.networkcredential_properties.aspx

Hope this helps,

Onur Güzel
 
Anthony P. said:
I'm using an URI object and I need to pass the url as follows:

http://ausername:[email protected]

The problem is that when VB.NET encounters the colon in the URL it
thinks it's a port and can't parse it. Is there a better way to pass
these credentials or, if not, how can I get around this?

As mentioned in the other post, use 'NetworkCredentials' instead. Note that
the above URI is actually /not/ a valid HTTP URI because HTTP URIs must not
contain credentials like FTP URIs, for example. Only some browsers support
credentials as part of HTTP URIs (this dangerous "feature" has been dropped
from IE some years ago).
 
Back
Top