Search code examples
c#asmxapp-config

Setting the service URL at runtime


When I am adding the "Web Reference" we are giving the address to the asmx page to visual studio.

How Can I set this at run time?


Solution

  • Just set the Url property of the object before you call any of the service methods:

    YourService service = new YourService();
    service.Url = "http://some.other.url/";
    
    // Now you're ready to call your service method
    service.SomeUsefulMethod();