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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:02:13+00:00 2026-06-07T06:02:13+00:00

I have trouble following the examples to get the callback. I have the following

  • 0

I have trouble following the examples to get the callback.

I have the following code:

 private void startWebRequest(object sender, EventArgs e)
    {
        Uri url = new Uri("http://localhost.com/dummyGet");
        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
        request.BeginGetResponse(new AsyncCallback(ReadWebRequestCallback), request);
    }

    private void ReadWebRequestCallback(IAsyncResult callbackResult)
    { 
        Console.WriteLine("Don not get here");
        try
        {
            var req = (HttpWebRequest)callbackResult.AsyncState;
            using (var response = req.EndGetResponse(callbackResult))
            {
                Console.WriteLine("Code");
            }
        }
        catch
        {  }
    }

I have been bangin my head against this all day, I can see the get request in my browser, or with client in fiddler/wireshark. But the code (ReadWebRequestCallback) does not get called.

Edit:
Also note that if I use WebClient and DownloadStringAsync it works, but i need other HTTP status codes than 404 and 200.:

_client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadStringCompleted);
_client.DownloadStringAsync(_concurrentCheckUrl);
}

private void DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
    {// Works, gets here}
  • 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-06-07T06:02:14+00:00Added an answer on June 7, 2026 at 6:02 am

    Thanks so much for all the help!

    I ended up with doing this like described in Simplify Async networking with Tasks in SL5 with tasks.

    HttpWebRequest _request;
    
    private void doGetRequest()
      _request = WebRequestCreator.ClientHttp.Create(new Uri("http://localhost/getDummy")) as HttpWebRequest;
            var webTask = Task.Factory.FromAsync<WebResponse>
                (_request.BeginGetResponse, _request.EndGetResponse, null)
              .ContinueWith(
                task =>
                {
                    var response = (HttpWebResponse)task.Result;
                    // The reason I use HttpRequest, not WebRequest, to get statuscode.
                    if (response.StatusCode == HttpStatusCode.ServiceUnavailable)
                    {
                         //Do Stuff
                    }
                });
    

    I do however think the problem relied in that my logging did not log when it was in the callback, this I cannot understand. But after banging my head to the wall for a day, I’ll leave that behind. But think my actual post would work.

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

Sidebar

Related Questions

I have trouble to get gluLookAt working. I have the following code which works
Sigh, regex trouble again. I have following in $text : [img]http://www.site.com/logo.jpg[/img] and [url]http://www.site.com[/url] I
I have trouble finding a solution for the following problem: I have a lot
I am having trouble with the following SQL statement. I have had this issue
Following this question and answer , I still have a bit trouble in the
Im having trouble with creating a JS bookmarklet, I have the following that when
I have trouble doing this... You may want to get the same result as
I'm having trouble understanding how to get the following working in interface builder. I've
I have trouble gripping to monads and monad transformers. I have the following contrived
I'm having a lot of trouble trying to get my Objective-C code to wait

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.