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 6606557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:24:31+00:00 2026-05-25T19:24:31+00:00

I have a requirement to implement a web-service that can issue files to the

  • 0

I have a requirement to implement a web-service that can issue files to the bits (Background Intelligent Transfer Service). The language is ASP.NET (C#). The problem I am having is with the “range” stuff.

My code currently receives the http request (with a valid range is present in the http headers of 0 – 4907), and subsequently dishes out a portion of a byte array in the response object.

Here’s my server code:

_context.Response.Clear();
_context.Response.AddHeader("Content-Range", "bytes " + lower.ToString() + "-" +  upper.ToString() + "//" + view.Content.Length.ToString());
_context.Response.AddHeader("Content-Length", upper.ToString());
_context.Response.AddHeader("Accept-Ranges", "bytes");
_context.Response.ContentType = "application/octet-stream";
_context.Response.BinaryWrite(data);
_context.Response.End();

What happens next is that the subsequent request does not have any “range” key in the header at all… it’s like it is asking for the entire file! Needless to say, the bits job errors stating that the servers response was not valid.

I suspect that it’s all down to the headers that the server is returning in the response object… I am pretty sure that I am following protocol here.

If anyone can help with this it would be greatly appreciated… mean while… I’ll keep on searching!

Regards

  • 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-25T19:24:32+00:00Added an answer on May 25, 2026 at 7:24 pm

    Yes, I found that I had a few issues in total. IIS was an initial problem, then my length calculations… and then like you say, the range request it’s self. Ignoring the latter, my final code for this segment was:

    _context.Response.StatusCode = 206;
    _context.Response.AddHeader("Content-Range", string.Format("bytes {0}-{1}/{2}", lower.ToString(), upper.ToString(), view.Content.Length.ToString()));
    _context.Response.AddHeader("Content-Length", length.ToString());
    _context.Response.AddHeader("Accept-Ranges", "bytes");
    _context.Response.OutputStream.Write(view.Content.ToArray(), lower, length);
    

    Handling multi-request ranges can be tackled a different day! Should BITS request in this way (like it does on the second request after the first request which asks for the entire file), my code simply returns nothing… and then BITS sends a single range in the request… things work ok from there.

    Thanks for the response.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a requirement to implement user privilege elevation in an MVC3 web app,
I have a WSDL that the consumer of my web service expects will be
I have a requirement to implement a web application using MVC 3, which works
I have a requirement for an ASP.NET web application whereby the same user is
Can an ASP.NET web application have only one Init and one Dispose method or
I have a requirement to implement an Unsaved Changes prompt in an ASP .Net
My requirement is to call WCF web service from ASP.NET code behind and pass
I have just received a requirement to implement spell checking on a web application
I am trying to implement a web service that accepts SOAP 1.2 over HTTP
I have a C# application that is a client to a web service. One

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.