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

  • Home
  • SEARCH
  • 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 982861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:45:56+00:00 2026-05-16T04:45:56+00:00

When making calls to a webservice from an asp.net web application, to avoid creating

  • 0

When making calls to a webservice from an asp.net web application, to avoid creating a new proxy for each webservice call, I store the proxy in a dictonary. So when a call to the webservice is being made, an instance of the webservice proxy is returned based on a key passed to a factory method. If a proxy for the corresponding key is already created, that proxy is returned. Otherwise, it creates a proxy for the key and returns the proxy.

This all works fine, unless the actual webservice for some reason “goes down” and don’t return any response. If that happens, which it in my case does pretty frequently, a System.Net.HttpWebRequest is created, which never gets collected by the GC. The reason is, the HttpWebRequest is a local variable in HttpWebRequest.GetResponse() which is still being executed (since it is waiting for a response that will never come). Hence, there exist a reference to HttpWebRequest that will keep the object alive.

One way to get around this would be to put the call to the webservice within a Using block, thereby disposing the object after the call has been made. That way, the references to the HttpWebRequest would be cut off so that the HttpWebRequest can be collected by the GC. However, by disposing the proxy, the whole idea of storing the proxy in a dictonary to avoid creating a proxy for each call malfunctions.

Hence, my question is, do anyone have any idea how I could do to solve the issue having references to the HttpWebRequests left when there is no response from the webservice?

Thanx in advance!

Some psuedo-code to explain the concept of storing the proxies in a dictonary:

public Proxy GetProxy(String key) {
            if(!proxies.ContainsKey(key)) {
                proxies[key] = new Proxy();
            }
            return proxies[key];
        }

public Object GetObject(String key) {
            Object object =
            this.GetProxy(key).GetObject();
            return object;
        }
  • 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-16T04:45:56+00:00Added an answer on May 16, 2026 at 4:45 am

    If the target site goes down, you’ll likely get a HttpException. Can you leverage that mechanism for managing the lifetime of your instances?

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

Sidebar

Ask A Question

Stats

  • Questions 542k
  • Answers 542k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use: SELECT p.id as a, p.url as b, t.id as… May 17, 2026 at 3:22 am
  • Editorial Team
    Editorial Team added an answer There are two parts to the problem First Issue You… May 17, 2026 at 3:19 am
  • Editorial Team
    Editorial Team added an answer I thought I'd show the regex approach, too. It doesn't… May 17, 2026 at 3:18 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm making asynchronous web service calls from a C# app: { //Put UI in
I've rewritten my family web site using JavaScript (JQuery) making Ajax calls to PHP
I am using a third-party application, and making a call to create an instance
I'm working on a web page where I'm making an AJAX call that returns
What's the best practice for making sure that certain ajax calls to certain pages
I was making the following call: result = RegOpenKeyEx(key, s, 0, KEY_READ, &key); (C++,
Making echo of a question around the web: Is the syntax for svn:ignore patterns
After making some changes in my models (eg. new field in a model and
Im making a small python script to upload files on the net. The script
We have a customer that is trying to call our web service written in

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.