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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:25:03+00:00 2026-05-27T13:25:03+00:00

I have a page which is fetching data from a webservice using async call.

  • 0

I have a page which is fetching data from a webservice using async call.
If i get the response from webservice control goes to catch where a message box is pooped.
The code is given below:

string uri = "http://free.worldweatheronline.com/feed/weather.ashx?key=b7d3b5ed25080109113008&q=Mumbai&num_of_days=5";
            UriBuilder fullUri = new UriBuilder("http://free.worldweatheronline.com/feed/weather.ashx");
            fullUri.Query = "key=b7d3b5ed25080109113008&q=Mumbai&num_of_days=5";
            HttpWebRequest forecastRequest = (HttpWebRequest)WebRequest.Create(fullUri.Uri);

            // set up the state object for the async request
            ForecastUpdateState forecastState = new ForecastUpdateState();
            forecastState.AsyncRequest = forecastRequest;

            // start the asynchronous request
            forecastRequest.BeginGetResponse(new AsyncCallback(HandleForecastResponse), forecastState);

This part is response

private void HandleForecastResponse(IAsyncResult asyncResult)
            {

                try
                {

                // get the state information
                ForecastUpdateState forecastState = (ForecastUpdateState)asyncResult.AsyncState;
                HttpWebRequest forecastRequest = (HttpWebRequest)forecastState.AsyncRequest;

                // end the async request
                forecastState.AsyncResponse = (HttpWebResponse)forecastRequest.EndGetResponse(asyncResult);

                Stream streamResult;
                string newCityName = "";
                //int newHeight = 0;


                // get the stream containing the response from the async call
                streamResult = forecastState.AsyncResponse.GetResponseStream();

                // load the XML
                XElement xmlWeather = XElement.Load(streamResult);

                }
                catch (Exception ex)
                {
                    MessageBox.Show("Connection Error");
                }
            }

Problem :
when the page is loaded it starts fetching data from webservice(consider the case when the web service is not responding and control goes to catch part).
In the mean time if we press the back button or navigate the page the message box popps on the new page.

How could i stop that.

Thanks and 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-27T13:25:03+00:00Added an answer on May 27, 2026 at 1:25 pm

    Finally solved it.

    catch (Exception x)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        var currentPage = ((App)Application.Current).RootFrame.Content as PhoneApplicationPage;
                        if ((currentPage.ToString()).Equals("MumbaiMarathon.Info.News"))
                        {
                            MessageBox.Show("Connection Error");
                        }
                    });
                }
    

    I just checked at the time of popping the message box the name of the Current UI application page. If its same as the page from which message box is initiated than it pops otherwise not.

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

Sidebar

Related Questions

I have a page which does an AJAX request to get data, which is
I have page which is redirected from htaccess. now I can pass the German
I have a page which requires retrieving results from a service, and that takes
I have a page, that has jqgrid, it is fetching json from a url.
I have a jScrollPane on a magento product page which is fetching in options
I have a CGI page with a table which is populated by fetching the
I have a page which has a couple option links that set GET-based parameters
I have a page which spawns a popup browser window. I have a JavaScript
I have a page which does quite a bit of work and I don't
I have a page which is largely created by DOM script, which generates a

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.