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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:50:58+00:00 2026-06-10T02:50:58+00:00

I’m trying to do a simple request to a web service. Code executes in

  • 0

I’m trying to do a simple request to a web service. Code executes in a background, not UI thread. Uri contains correct address which always return result with 200 HTTP code. Everything goes on emulator.

var request = WebRequest.Create(uri);
try
{
    var ar = request.BeginGetResponse(_ => { }, null);
    using (var response = request.EndGetResponse(ar)) //NullReferenceException rises here
    using (var stream = response.GetResponseStream())
    {
        var serializer = new DataContractJsonSerializer(typeof(AuthResult));
        return (AuthResult)serializer.ReadObject(stream);
    }
}
catch (Exception e)
{
    return new AuthResult { Error = e.Message };
}

Without debugger code always fails. When debugger attached it fails quite rarely.

System.NullReferenceException occurred
  Message=NullReferenceException
  StackTrace:
   at System.Net.Browser.ClientHttpWebRequest.InvokeGetResponseCallback(Object state)
   at System.Net.Browser.ClientHttpWebRequest.Completed(Object sender, EventArgs e)
   at MS.Internal.InternalWebRequest.OnCompleted(Object sender, EventArgs args)
   at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

And the next one:

System.Net.WebException occurred
Message=The remote server returned an error: NotFound.
StackTrace:
   at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at Contest.InteropApi.SignIn(Uri uri)
   at Contest.ViewModel.LoginViewModel.<PerformSignIn>b__4()
   at System.Reactive.Linq.QueryLanguage.<>c__DisplayClass3b`1.<>c__DisplayClass3d.<ToAsync>b__3a()
   at System.Reactive.Concurrency.Scheduler.Invoke(IScheduler scheduler, Action action)
   at System.Reactive.Concurrency.DefaultScheduler.<>c__DisplayClass1`1.<Schedule>b__0(Object _)
   at System.Reactive.Concurrency.ConcurrencyAbstractionLayerImpl.<>c__DisplayClasse.<QueueUserWorkItem>b__d(Object _)
   at System.Threading.ThreadPool.WorkItem.WaitCallback_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadPool.WorkItem.doWork(Object o)
   at System.Threading.Timer.ring()
  • 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-10T02:51:00+00:00Added an answer on June 10, 2026 at 2:51 am

    Http is used asynchronously – you have to call EndGetResponse in the callback (first parameter) of the BeginGetResponse method. Your code calls EndGetResponse at a time the response is not ready.

    Check out the sample at the end of this website:
    http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest%28v=vs.95%29.aspx

    Maybe this http classes help you making http calls:
    http://mytoolkit.codeplex.com/wikipage?title=Http

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

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping a
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.