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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:16:39+00:00 2026-05-23T20:16:39+00:00

I use in my code calls to HttpWebRequest.BeginGetResponse() method to get data from my

  • 0

I use in my code calls to HttpWebRequest.BeginGetResponse() method to get data from my server. The server produces content that may range from few KB to few GB.

My problem is that HttpWebRequest.BeginGetResponse completes too late. It should complete immediately after the connection to the server is established and the HTTP header is received.

Here is sample code using GET method:

public bool StartDownload()
{
    try
    {
        HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(m_getUrl);
        myHttpWebRequest.Method = "GET";

        // Start the asynchronous request.
        m_requestState = new RequestState();
        m_requestState.request = myHttpWebRequest;

        myHttpWebRequest.BeginGetResponse(new AsyncCallback(ResponseCompleted), m_requestState);
    }
    catch (Exception)
    {
        m_requestState = null;
    }

    return m_requestState != null;
}

private void ResponseCompleted(IAsyncResult result)
{
    RequestState myRequestState = (RequestState)result.AsyncState;
    HttpWebRequest myHttpWebRequest = myRequestState.request;

    m_logger.LogMessage("ResponseCompleted notification received!");

    HttpWebResponse response = null;
    try
    {
        response = (HttpWebResponse)myHttpWebRequest.EndGetResponse(result);
    }
    catch (Exception)
    {
    }
    .......
}

I run the code using “http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.39.1.tar.bz2” for example and the result looks like:

hh:mm:ss.ms
12:51:30.9440000 - Download started!
12:53:04.8520000 - ResponseCompleted notification received!
12:53:04.8560000 - Header received!
12:53:04.8570000 - DataReceived: 524288 bytes
.........................................
12:53:04.8940000 - DataReceived: 78818 bytes
12:53:04.8940000 - Request data received!
12:53:04.8940000 - Received bytes: 76100578

The problem can be easily detected in the log. It is not possible to spend more that one minute to connect and 38 ms to download about 72.5 MB.
It seems that the data is downloaded somewhere on the phone and the RequestComplete notification is sent to the application only when the full content is available locally. This is not OK for me because I need to show progress for the operation.

I get the same result on the device and emulator for WP7 (also on WP7.1).

I run same code on Windows desktop and it run correctly: the request completes within one second and the rest of the download takes about 1-2 minutes.

Is there any solution on WP7 or WP 7.1?
The newly introduced WP 7.1 API “Background File Transfers” does not help because I need full control over the HTTP headers and content. Not all HTTP requests that I make to the server produce files as output.

Thank you!
Mihai

  • 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-23T20:16:39+00:00Added an answer on May 23, 2026 at 8:16 pm

    You need to disable response buffering if you want to stream the data down. You can do this by setting AllowReadStreamBuffering to false.

    HttpWebRequest myHttpWebRequest = WebRequest.CreateHttp(m_getUrl);
    myHttpWebRequest.Method = "GET";
    myHttpWebRequest.AllowReadStreamBuffering = false;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I use HttpWebRequest.BeginGetResponse and get progress changed events for the upload of
I have C# wrapper code that calls functions from a native (C++) dll. Currently,
I am trying to verify that my Rails code calls ActiveRecord's all method (all
Do you use code-generation tools (aside from those used to generate proxies and from
When I try to use the code below I get a duplicate variable error
I have some code (which I cannot change) that I need to get working
Looking on some source code I've inherited, there's a snippet of code that calls
How would i get the value of a radio button and use that in
I have C code that calls C++ code. The C++ code creates an object
I am trying to use some pinvoke code to call a C function. The

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.