Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 502471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:17:41+00:00 2026-05-13T06:17:41+00:00

Background – I’m trying to stream an existing webpage to a separate web application,

  • 0

Background – I’m trying to stream an existing webpage to a separate web application, using HttpWebRequest/HttpWebResponse in C#. One issue I’m striking is that I’m trying to set the file upload request content-length using the file download’s content-length, HOWEVER the issue seems to be when the source webpage is on a webserver for which the HttpWebResponse doesn’t provide a content length.

HttpWebRequest downloadRequest = WebRequest.Create(new Uri("downloaduri")) as HttpWebRequest;
 using (HttpWebResponse downloadResponse = downloadRequest.GetResponse() as HttpWebResponse)
 {
   var uploadRequest = (HttpWebRequest) WebRequest.Create(new Uri("uripath"));
   uploadRequest.Method = "POST";
   uploadRequest.ContentLength = downloadResponse.ContentLength;  // ####

QUESTION: How could I update this approach to cater for this case (when the download response doesn’t have a content-length set). Would it be to somehow use a MemoryStream perhaps? Any sample code would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:17:41+00:00Added an answer on May 13, 2026 at 6:17 am

    If you’re happy to download the response from the other web server completely, that would indeed make life easier. Just repeatedly write into a MemoryStream as you fetch from the first web server, then you know the length to set for the second request and you can write the data in easily (especially as MemoryStream has a WriteTo method to write its contents to another stream).

    The downside of this is that you’ll take a lot of memory if it’s a large file. Is that likely to be a problem in your situation? Alternatives include:

    • Writing to a file instead of using a MemoryStream. You’ll need to clean up the file afterwards, of course – you’re basically using the file system as bigger memory 🙂
    • Using a chunked transfer encoding to “read a chunk, write a chunk”; this may be fiddly to get right – it’s certainly not something I’ve done before.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

background-position: -200px 0; one site says it crops an image from the bottom and
Background I'm using SendKeys() to send keyboard commands to the active window, but I'm
Background: I'm using a delegation technique to abstract access to arbitrary object methods, but
Background: On a recent website, I'm using a jQuery driven dropdown menu in addition
Background Looking to automate creating Domains in JasperServer. Domains are a view of data
Background This is the same background as my previous question , except the Outline
Background: I’ve inherited a project, about 10k loc implementing an odbc driver. To configure
Background I've got the following tree of objects: Name Project Users nil John nil
Background: I have a MainTest class that has many buttons, each of which instantiate
Background: I've implemented a stochastic algorithm that requires random ordering for best convergence. Doing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.