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?
+1
A:
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();
Justin Niessner
2010-06-08 13:55:12
+1
A:
YourWebService service = new YourWebService();
service.Url = "http://www.example.com/YourWebService.asmx";
service.CallMethod();
Robin Day
2010-06-08 13:57:28
+2
A:
I would have upvoted one of the other answers - they're almost correct.
using (YourService service = new YourService())
{
service.Url = "http://some.other.url/";
// Now you're ready to call your service method
service.SomeUsefulMethod();
}
If a using block is not used, and an exception is thrown, then resources like network connections can be leaked.
John Saunders
2010-06-08 20:19:31