Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sir,

I have created a simple web service and trying to access it from asp .net. But i am getting an error message that "WebException was unhandlled by user code . Unable to connect to the remote server." Previously it was working properly. I think some setting hag been changed. I have reinstalled .net also. Still it is not working.

I am not able to send email also. I am getting same error lile "Unable to connect to remote server"

Plz help me how can i rectify this problem.


This is my Code
-----------------
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

/// <summary>
/// Summary description for ws
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class ws : System.Web.Services.WebService {

    public ws () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }
    
}

 protected void Page_Load(object sender, EventArgs e)
    {
        helloworldws.ws obj = new helloworldws.ws();
        string result = obj.HelloWorld();
        Response.Write(result);
    

    }
Posted
Updated 8-May-12 20:09pm
v2
Comments
Sandeep Mewara 9-May-12 2:10am    
Have you refreshed your webservice reference? Is your webservice up and running? Can you access it through browser?

1 solution

If you cannot browse by machine name it means you have networking issues to resolve. For example it can be firewall settings preventing remote connections. Or, perhaps, your web service is hosted by VS's test host and not by IIS. You must use IIS for hosting as VS test host does not allow for remote connections at all.

127.0.0.1 and localhost (which is indeed the same) would never work as device/emulator would try to connect to itself and I seriously doubt you’ve managed to install IIS on to the device and running WS on it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900