473,406 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Downloading a document form a web Server

I'm trying to download a document to a machine using the documents URL. I've been playing around with the HTTPWebRequest object but without any joy.

My code is

wrWebRequest = (HttpWebRequest)WebRequest.Create(strDocURL);
wrWebRequest.Credentials = System.Net.CredentialCache.DefaultCredentials;
wrWebRequest.Method = "POST";

StreamReader Stream = new StreamReader(wrWebReq.GetRequestStream());
The error I get is Stream was not Readable.

Any Thoughts?
Andrew
Nov 16 '05 #1
6 6059
Should'nt you use HTTP method GET instead of POST?
"Andrew" <an**@nospam.com> wrote in message
news:g2********************************@4ax.com...
I'm trying to download a document to a machine using the documents URL. I've been playing around with the HTTPWebRequest object but without any joy.
My code is

wrWebRequest = (HttpWebRequest)WebRequest.Create(strDocURL);
wrWebRequest.Credentials = System.Net.CredentialCache.DefaultCredentials;
wrWebRequest.Method = "POST";

StreamReader Stream = new StreamReader(wrWebReq.GetRequestStream());
The error I get is Stream was not Readable.

Any Thoughts?
Andrew

Nov 16 '05 #2
When I do a GET I get the error - 'Cannot send a content-body with this verb type'.

On Fri, 2 Jul 2004 10:37:55 +0200, "Dennis Myrén" <de****@oslokb.no> wrote:
Should'nt you use HTTP method GET instead of POST?
"Andrew" <an**@nospam.com> wrote in message
news:g2********************************@4ax.com.. .
I'm trying to download a document to a machine using the documents URL.

I've been playing around with the HTTPWebRequest object but without any joy.

My code is

wrWebRequest = (HttpWebRequest)WebRequest.Create(strDocURL);
wrWebRequest.Credentials = System.Net.CredentialCache.DefaultCredentials;
wrWebRequest.Method = "POST";

StreamReader Stream = new StreamReader(wrWebReq.GetRequestStream());
The error I get is Stream was not Readable.

Any Thoughts?
Andrew


Nov 16 '05 #3
You are using GetRequestStream, try GetResponse instead:

StreamReader sr = new
StreamReader(System.Net.WebRequest.Create(url).Get Response().GetResponseStre
am());

"Andrew" <an**@nospam.com> wrote in message
news:33********************************@4ax.com...
When I do a GET I get the error - 'Cannot send a content-body with this verb type'.
On Fri, 2 Jul 2004 10:37:55 +0200, "Dennis Myrén" <de****@oslokb.no> wrote:
Should'nt you use HTTP method GET instead of POST?
"Andrew" <an**@nospam.com> wrote in message
news:g2********************************@4ax.com.. .
I'm trying to download a document to a machine using the documents URL.

I've been playing around with the HTTPWebRequest object but without any joy.

My code is

wrWebRequest = (HttpWebRequest)WebRequest.Create(strDocURL);
wrWebRequest.Credentials = System.Net.CredentialCache.DefaultCredentials; wrWebRequest.Method = "POST";

StreamReader Stream = new StreamReader(wrWebReq.GetRequestStream());
The error I get is Stream was not Readable.

Any Thoughts?
Andrew

Nov 16 '05 #4
Andrew wrote:
I'm trying to download a document to a machine using the documents
URL. I've been playing around with the HTTPWebRequest object but
without any joy.

My code is

wrWebRequest = (HttpWebRequest)WebRequest.Create(strDocURL);
wrWebRequest.Credentials =
System.Net.CredentialCache.DefaultCredentials;
wrWebRequest.Method = "POST";

StreamReader Stream = new StreamReader(wrWebReq.GetRequestStream());
The error I get is Stream was not Readable.

Any Thoughts?


Sure. Don't read the request stream. Read the *response* stream.
--
Joerg Jooss
jo*********@gmx.net
Nov 16 '05 #5
Hi Andrew,

StreamReader Stream = new StreamReader(wrWebReq.GetRequestStream());
--> Stream is part of System.IO.Stream, name it strmRead or anything else.

Maybe you should name it something else.

Good Luck! Correct me if i am wrong.
--
Regards,
Chua Wen Ching :)
"Andrew" wrote:
When I do a GET I get the error - 'Cannot send a content-body with this verb type'.

On Fri, 2 Jul 2004 10:37:55 +0200, "Dennis Myrén" <de****@oslokb.no> wrote:
Should'nt you use HTTP method GET instead of POST?
"Andrew" <an**@nospam.com> wrote in message
news:g2********************************@4ax.com.. .
I'm trying to download a document to a machine using the documents URL.

I've been playing around with the HTTPWebRequest object but without any joy.

My code is

wrWebRequest = (HttpWebRequest)WebRequest.Create(strDocURL);
wrWebRequest.Credentials = System.Net.CredentialCache.DefaultCredentials;
wrWebRequest.Method = "POST";

StreamReader Stream = new StreamReader(wrWebReq.GetRequestStream());
The error I get is Stream was not Readable.

Any Thoughts?
Andrew


Nov 16 '05 #6
Got it - Thanks

On Fri, 2 Jul 2004 10:55:59 +0200, "Dennis Myrén" <de****@oslokb.no> wrote:
You are using GetRequestStream, try GetResponse instead:

StreamReader sr = new
StreamReader(System.Net.WebRequest.Create(url).Ge tResponse().GetResponseStre
am());

"Andrew" <an**@nospam.com> wrote in message
news:33********************************@4ax.com.. .
When I do a GET I get the error - 'Cannot send a content-body with this

verb type'.

On Fri, 2 Jul 2004 10:37:55 +0200, "Dennis Myrén" <de****@oslokb.no>

wrote:
>Should'nt you use HTTP method GET instead of POST?
>"Andrew" <an**@nospam.com> wrote in message
>news:g2********************************@4ax.com.. .
>> I'm trying to download a document to a machine using the documents URL.
>I've been playing around with the HTTPWebRequest object but without anyjoy. >>
>> My code is
>>
>> wrWebRequest = (HttpWebRequest)WebRequest.Create(strDocURL);
>> wrWebRequest.Credentials =System.Net.CredentialCache.DefaultCredentials; >> wrWebRequest.Method = "POST";
>>
>> StreamReader Stream = new StreamReader(wrWebReq.GetRequestStream());
>>
>>
>> The error I get is Stream was not Readable.
>>
>> Any Thoughts?
>> Andrew
>


Nov 16 '05 #7

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

Similar topics

2
by: Ian Gordon | last post by:
Hi, I have 2 problems when downloading a file from my ASP.net app to the client PC. At the moment I'm doing it with the following code: Response.ContentType = "application/octet-stream" ...
2
by: Earl Teigrob | last post by:
I am trying to build a custom control to wrap my smart navigation implimention (not microsofts 'cause it has problems) The follow code works fine when the onclick and onload events are defined in...
4
by: Joe | last post by:
I'm hosting my web service on a Windows 2003 box which is remotely located. When trying to add a web reference to a C# project I get an error message 'There was an error downloading...
1
by: just.starting | last post by:
Hi, My dot net client downloads files and checks for any new files time to time. The server is apache2.0.53 server. So what happens is that my file download thing works fine if I dont try to call...
3
by: just.starting | last post by:
Hi, My dot net client downloads files and checks for any new files time to time. The server is apache2.0.53 server. So what happens is that my file download thing works fine if I dont try to call...
23
by: Doug van Vianen | last post by:
Hi, Is there some way in JavaScript to stop the downloading of pictures from a web page? Thank you. Doug van Vianen
2
by: tamaker | last post by:
I have a registration form where a user is able to, upon submission of the form, have their submission entered into a simple database... now Im looking to create a word document on the fly from...
6
by: cyusman | last post by:
Hi, We have just moved our application to a new webfarm server environment which utilizing hardware load balancing, SSL off-loading and HTTP compression off-loading.My application is running on...
4
by: surja | last post by:
Hi, I have written a code to download images from a server end desktop, but while running the code ,WTK is showing a runtime error " Create image from Byte array Uncaught exception...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.