all groups > dotnet jscript > february 2007 >
You're in the

dotnet jscript

group:

How do NetworkCredential and WebClient work?


How do NetworkCredential and WebClient work? Tosco
2/4/2007 3:15:11 PM
dotnet jscript: I read many examples with NetworkCredential and WebClient, but no one
with a real http address.
They all work in theory, but I wasn't able to use them in the real
world.
The following code should access an ebay page. There is no
redirection involved in TestPage. If you have an ebay account you can
try it in 1 minute.

What's wrong with my code?

Dim UserName As String = "stenci"
Dim Password As String = "vivalafica"
Dim TestPage As String = _
"http://my.ebay.com/ws/eBayISAPI.dll?MyeBay&MyeBay=" _
& UserName
Dim Cli As New Net.WebClient

Dim Txt1 = Cli.DownloadString(TestPage)
IO.File.WriteAllText("C:\1.txt", Txt1)

Cli.Credentials = New Net.NetworkCredential(UserName, _
Password)

Dim Txt2 = Cli.DownloadString(TestPage)
IO.File.WriteAllText("C:\2.txt", Txt2)

MsgBox("Before setting credentials is not logged=" & _
InStr(Txt1, "Sign In: My eBay") & " is logged=" _
& InStr(Txt2, "Sign In: My eBay"))

MsgBox("After setting credentials is not logged=" & _
InStr(Txt1, "My Summary") & " is logged=" _
& InStr(Txt2, "My Summary"))

Thanks,
Stefano
Re: How do NetworkCredential and WebClient work? Herfried K. Wagner [MVP]
2/5/2007 12:31:39 AM
"Tosco" <stefano.menci@gmail.com> schrieb:
[quoted text, click to view]

eBay uses a different authentication approach similar to those used by
Google:

<URL:http://dotnet.mvps.org/dotnet/code/net/#CookieRequest>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
AddThis Social Bookmark Button