WebClient Not posting to Client

Discussion in 'ASP .Net Web Services' started by Tom, Feb 1, 2005.

  1. Tom

    Tom Guest

    Anyone know how to post a file to the client using
    WebClient?
    My usage is posting it to the Web Server.
    How do you tell the object to post to the client?

    I copied the code from the Microsoft site for examples of
    text file downloads using WebClient, but it only copies
    to the Web Server. I've tried the 'DownloadFile'
    function, obviously, as well.

    .... (it reads just fine.)
    string TheirAddress = "C:\\temp\\client.zip";
    System.IO.Stream TheirStream = MyClient.OpenWrite
    (TheirAddress);

    byte [] buf = new byte[1024];
    int len = 0;
    //loop through the stream and put the output in the
    textbox.
    while((len = MyStream.Read(buf,0,buf.Length))!=0)
    {
    //textOutput.AppendText(NewLine+"\r\n");
    TheirStream.Write(buf,0,len );
    }
    Tom, Feb 1, 2005
    #1
    1. Advertising

  2. Tom

    Tom Guest

    Sorry. I used the wrong terminology.
    I meant the WebClient class is not DOWNLOADING a file to
    the client. The Web Server copies the file to itself when
    using destination: "C:\\temp\\client.zip". I would have
    thought that the WebClient class would take this path to
    be on the Client--- but it does not. It takes the path to
    be on the Web Server that it is executing on.

    I was wondering how do you tell the WebClient class to
    copy the file to the Clients' hard drive?...from the info
    I've been reading, this is what I was led to believe was
    the functionality of "WebClient". It seems I'm missing a
    piece of the puzzle... of how to 'Focus' the WebClient
    class to the client. Is there something in the background
    I need to be setting?

    Uploading from client to Web Server seems to be a piece
    of cake. There are plenty of options to use for that and
    they all seem to work. Thanks.

    Hope you follow this thread. I appreciate you responding.

    >-----Original Message-----
    >Try the WebRequest class if you want to POST data to a

    web server. The
    >WebClient class expects a that's able to handle the file

    upload, for
    >example file the file upload server control, at the

    destination.
    >
    >HTH,
    >Christoph Schittko
    >MVP XML
    >http://weblogs.asp.net/cschittko
    >
    >
    >
    >> -----Original Message-----
    >> From: Tom [mailto:]
    >> Posted At: Tuesday, February 01, 2005 10:38 AM
    >> Posted To:

    microsoft.public.dotnet.framework.aspnet.webservices
    >> Conversation: WebClient Not posting to Client
    >> Subject: WebClient Not posting to Client
    >>
    >> Anyone know how to post a file to the client using
    >> WebClient?
    >> My usage is posting it to the Web Server.
    >> How do you tell the object to post to the client?
    >>
    >> I copied the code from the Microsoft site for examples

    of
    >> text file downloads using WebClient, but it only copies
    >> to the Web Server. I've tried the 'DownloadFile'
    >> function, obviously, as well.
    >>
    >> ... (it reads just fine.)
    >> string TheirAddress = "C:\\temp\\client.zip";
    >> System.IO.Stream TheirStream = MyClient.OpenWrite
    >> (TheirAddress);
    >>
    >> byte [] buf = new byte[1024];
    >> int len = 0;
    >> //loop through the stream and put the output in the
    >> textbox.
    >> while((len = MyStream.Read(buf,0,buf.Length))!=0)
    >> {
    >> //textOutput.AppendText(NewLine+"\r\n");
    >> TheirStream.Write(buf,0,len );
    >> }

    >
    >.
    >
    Tom, Feb 2, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Baker

    WebClient form Posting with form name?

    Jeff Baker, Aug 28, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    747
    John Saunders
    Aug 29, 2003
  2. alanb
    Replies:
    2
    Views:
    520
    alanb
    Apr 23, 2004
  3. Manuel

    WebClient not posting data.

    Manuel, Nov 2, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    6,619
    Joerg Jooss
    Nov 3, 2004
  4. AmitKu
    Replies:
    7
    Views:
    499
    John Timney \(MVP\)
    Jan 8, 2007
  5. Harvey Triana
    Replies:
    4
    Views:
    2,138
    George Ter-Saakov
    Feb 8, 2008
Loading...

Share This Page