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 : I currently have a Web Forms, ASP.NET 3.5/C# application which I'm interested
Background Developing a simple web application (Eclipse + JBoss + Apache Tomcat) to generate
Background: At my company we are developing a bunch applications that are using the
Background: Some time ago, I built a system for recording and categorizing application crashes
Background I am writing and using a very simple CGI-based (Perl) content management tool
Background I am trying to create a copy of a business object I have
Background We have a Windows .NET application used by our field employees who travel
Background: I'm working on a system where the developers seem to be using a
Background I'm trying to get obtain a unique identifier out of a computer and
Background: I'm using Google's protobuf , and I would like to read/write several gigabytes

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.