No connection could be made because the target machine actively refused it

Discussion in 'ASP .Net' started by hufaunder, Jul 24, 2006.

  1. hufaunder

    hufaunder Guest

    I have a website that consumes a webservice. Both of them are in the
    Default Website folder. I can execute the service without any problem
    when I go to the test page http://localhost/Service.asmx. When I try to
    consume that webservice from the website I get the error shown bellow.
    In my web.config I have:

    <authentication mode="Windows"/>
    <identity impersonate="true" userName="auser" password="apwd"/>

    IIS is configured as "Integrated Windows authentication" and "Enable
    anonymous access" is disabled.

    System.Security.Principal.WindowsIdentity.GetCurrent().Name returns

    I am struggling with that for a LONG time so any help is greatly



    "No connection could be made because the target machine actively
    refused it
    Description: An unhandled exception occurred during the execution of
    the current web request. Please review the stack trace for more
    information about the error and where it originated in the code.

    Exception Details: System.Net.Sockets.SocketException: No connection
    could be made because the target machine actively refused it

    Line 110: object[] results = this.Invoke("MyWebservice", new
    object[] {

    Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary
    ASP.NET Files\root\26676eb7\92c7e946\App_WebReferences.rglqbs34.0.cs
    Line: 110 "
    hufaunder, Jul 24, 2006
    1. Advertisements

  2. Since it works locally, we can almost rule out a problem with IIS. But can
    you please verify that IIS binds to the IP address that you are trying to
    connect to from a remote machine?

    Is it possible that you have a firewall enabled (Windows XP's or a
    third-party firewall) that could be blocking remote requests on port 80
    (assuming that is the port you use)?
    Kristofer Gafvert, Jul 24, 2006
    1. Advertisements

  3. local accounts generally do not have network access. you should use a domain

    -- bruce (
    bruce barker \(\), Jul 24, 2006
  4. hufaunder

    hufaunder Guest

    Thanks for the reply. Actually, I cannot connect even on my local
    machine. If I go to the test site of the webservice it works
    (http://localhost/Service.asmx) but http://localhost/MyWebservice.aspx
    which uses the webservice does not.


    hufaunder, Jul 24, 2006
  5. What is your IIS configuration look like? Is Anonymous access disabled? IE
    is probably doing the NTLM authentication automatically. The website won't
    do that. Try disabling integrated authentication on IIS itself and enable
    only Anonymous access. I'd bet that fixes the problem. Hope this helps.

    John Swanagon
    Sr. Software Engineer, Avaya Labs
    Avaya Inc.
    Swanagon, John M \(John\), Jul 24, 2006
  6. hufaunder

    hufaunder Guest

    My IIS configuration is "Integrated Windows authentication" and "Enable

    anonymous access" is disabled. The reason I am using impersonation is
    because I need the additional access rights.

    hufaunder, Jul 24, 2006
  7. Ah, got it. Then, in that case, all you need to do is authenticate to the
    webserver before your site will be able to access the web service. I
    believe it would involve providing the correct headers telling the server to
    use NTLM authentication. Since your website is using impersonation, the
    context for NTLM should exist in order for it to work properly. I don't
    know the code right off-hand, but if you want, I could write something up
    and post it here. Just let me know...


    Swanagon, John M \(John\), Jul 24, 2006
  8. hufaunder

    hufaunder Guest

    If you could show me some code that leads me in the right direction
    that would be very much appreciated. I'm a novice with this stuff and
    really didn't get a good grip on authentication yet.


    hufaunder, Jul 25, 2006
  9. Sure, will do. I will post here in a little bit.


    Swanagon, John M \(John\), Jul 25, 2006
  10. hufaunder


    May 10, 2007
    Likes Received:
    "I have a website that consumes a webservice. Both of them are in the
    Default Website folder."

    I found this post 2 days ago, as I had the same problem. I've just now resolved it, so I thought I'd throw in my solution.

    Anonomous access and windows authentication are checked for all pages and folders.

    NTLM auth is checked.

    No changes of any of these were required, though I saw references to these things several times along the way.

    The Key (for me) was in the quoted section above. Both my web service and the consuming .aspx page were in the same default folder. This does not work.

    Instead, build a virtual directory in your wwwroot (authentication as above).

    Inside that directory, build the service (I followed these exact insructions and then copied my web service code over top of the default code: ( never mind the credential steps, I never had to go there, you may need to continue, though). (The instructions specified to "Build" the service, which I did. I don't know if it would work if you missed this step).

    Ok, Service is built in the virtual directory, take a breath or two.

    Go back to your main site (in my case, open up the site in Visual Web Dev).

    Click "Website > Add Web Reference"

    Select the appropriate service, and click through the steps. Now, VWD will build the disco, discomap, and wsdl pages for you. These refer to the web service that you've selected. However, your web.config file might also have a reference to the location of the web service, and this won't update automatically. Open any one of the automatically built reference files and copy from them the URL of the web service (in my case, http://localhost/AmericanSolarPowerCentral/YahooQuoteWebService.asmx). Paste this URL into the appropriate section of your web.config file.

    In my case, at this point my aspx was properly consuming my web service.

    ytterbius, May 10, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.