agarcian
agarcian

Reputation: 3965

How to implement Javascript's XmlHttpRequest in C#?

There is an old article in the MSDN Magazine with a walk-through to implement in C# the equivalent of the Javascript XMLHttpRequest object.

I find it very interesting but the code is not downloadable anymore.

Do you know of an implementation similar to the Javascript XMLHttpRequest object but in C#? Among other thinks, this implementation can:

I know it all can be done easily with the HTTPWebRequest object in .NET, but after reading the article I was hoping that a wrapper would be available as it used to be in the code of that article (the link is dead).

Thanks,

Upvotes: 0

Views: 1830

Answers (3)

Jon Hanna
Jon Hanna

Reputation: 113282

You can use WebClient, though I often find it wraps a bit too much and I end up going back to HTTPWebRequest.

There's plenty of the code from that article in it's figures at http://msdn.microsoft.com/hr-hr/magazine/bb985675%28en-us%29.aspx Enough really to reconstruct the whole thing.

Upvotes: 1

Felice Pollano
Felice Pollano

Reputation: 33252

You can use WebClient.DownloadString that is a good wrapper around a web request. You can have a non blocking call too ( the better way ) by using DownloadStringAsync

Upvotes: 2

dtb
dtb

Reputation: 217313

Have a look at the WebClient Class.

Upvotes: 4

Related Questions