473,770 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do NetworkCredenti al and WebClient work?

I read many examples with NetworkCredenti al 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?M yeBay&MyeBay=" _
& UserName
Dim Cli As New Net.WebClient

Dim Txt1 = Cli.DownloadStr ing(TestPage)
IO.File.WriteAl lText("C:\1.txt ", Txt1)

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

Dim Txt2 = Cli.DownloadStr ing(TestPage)
IO.File.WriteAl lText("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

Feb 4 '07 #1
2 3965
"Tosco" <st***********@ gmail.comschrie b:
>I read many examples with NetworkCredenti al and WebClient, but no one
with a real http address.
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/>

Feb 4 '07 #2
eBay uses a different authentication approach similar to those used by
Google:

<URL:http://dotnet.mvps.org/dotnet/code/net/#CookieRequest>
Thank you Herfried, but I don't understand the german part, I can only
look at the code examples, and it doesn't help.
I think the part that I need in that page is this:

Dim Client As New WebClient()
Client.Headers. Add("Content-Type", "applicatio n/x-www-form-
urlencoded")
Client.UploadDa ta( _
"https://www.google.com/adsense/login.do", _
"POST", _
Encoding.UTF8.G etBytes("userna me=<user name>&password= <password>")
_
)
Client.Headers. Clear()
Client.Headers. Add("Cookie", Client.Response Headers("Set-Cookie"))
Dim Data() As Byte = _
Client.Download Data("https://www.google.com/adsense/report/
overview")
Client.Dispose( )
MsgBox(Encoding .UTF8.GetString (Data))

I tried to use it for ebay (I actually need it in 2 different domains,
but I hope than after succeding with ebay once I will be able to use
it with the other urls) and it didn't work.
This is what I did:

Dim UserName As String = "username"
Dim Password As String = "password"
Dim Client As New Net.WebClient()
Client.Headers. Add("Content-Type", "applicatio n/x-www-form-
urlencoded")
Client.UploadDa ta( _
"https://signin.ebay.com/ws/eBayISAPI.dll", _
"POST", _
System.Text.Enc oding.UTF8.GetB ytes( _
"MfcISAPIComman d=SignInWelcome &siteid=0&co_pa rtnerId=2&" & _
"UsingSSL=1&ru= &pp=&pa1=&pa2=& pa3=&i1=-1&pageType=-1&userid="
_
& UserName & "&pass=" & Password))
Client.Headers. Clear()
Client.Headers. Add("Cookie", Client.Response Headers("Set-Cookie"))
Dim Data() As Byte = _
Client.Download Data("http://my.ebay.com/ws/eBayISAPI.dll?
MyeBay")
Client.Dispose( )
MsgBox(System.T ext.Encoding.UT F8.GetString(Da ta))

Stefano

Feb 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
13303
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType = "application/octet-stream"; Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileID.ToString() + ".pdf");
7
3943
by: Crirus | last post by:
Hi all! I use a webClient for requesting data from a server of mine. Should I worry about long ammount of data sent by server in the client side? Or, another way, should I send some kind of a terminator sign in the data in order to realise in the client that all data arrived? -- Ceers, Crirus
3
6932
by: Patrick Fogarty | last post by:
I am programming what is to be a web service client that will use an HTTP-POST to request and retrieve data. The remote server (written in java for what it's worth) requires basic authentication as per RFC 2617 (http://www.faqs.org/rfcs/rfc2617.html). My attempts to authenticate are failing. The server requires the header to be present with the request. For security reasons, it will not reply in any way if the header is not present. ...
6
22105
by: Giovanni | last post by:
Hi Guys, Really strange problem I am experiencing... I have setup a virtual directory with Read Only permissions on an ISA/IIS server (SBS 2003). In that virt. dir., I placed 1 file (setup.exe). I then use WebClient.DownloadFileAsync (.NET 2.0 Pro.) and all downloads well including progress bar indicator, bytes received, etc... Here is the problem: When I replace the file (setup.exe), with a different, larger file, it still...
1
6292
by: vin.dor | last post by:
Dear All, I am using WebClient in my Visual Studio .Net 2003 project to download an image from the Internet. The following is my function: C# Code: public static bool downloadFile(string URL, ref string fileName) { bool result = true;
4
7783
by: Lehel Kovach | last post by:
I'm having a problem with the WebClient object. When I post data to certain sites, it will receive a command from the webserver (object moved) and continue to the next link by downloading that. The problem is, certain cookies need to be set, and the only way of doing that is not letting the WebClient automatically go on to the next GET in the background--I need to do it manually. I'm wondering if this has something to do with the...
2
2693
by: Tosco | last post by:
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?
1
7638
by: Guy | last post by:
I use SmtpClient to send mail. My customer reported that sending mail was throwing an exception on his machine "the SMPT client requires a secure connection or the client was not authenticated". so I now provide credentials with my request, however it sends mail all the time, whichever username or password I use. I even removed the password from my Outlook account options. Sends mail anyway ? Is there a credential cache in Windows...
2
10173
by: MichaelSchoeler | last post by:
Hi, I'm having problems with the WebClient class regarding UTF-8 encoded data. When I access a specific webservice directly I can see the data arrives in corretly formatted UTF-8. But when I try to pull data from the same webservice url through the WebClient class I get partly garbled UTF-8 data in return. Only some UTF-8 chars (double byte pairs) seems to be corrupted. // Does not work WebClient wc = new WebClient(); string...
0
9595
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9432
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10059
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8891
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7420
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.