I’m creating a web service (asmx) in c# and everything works fine except that everyone can connect to it. What I want to do is enable user-password protection (web service is hosted by iis 7.5) so client would use it like this:
using(var client = new SoapClient())
{
client.ClientCredentials.UserName.UserName = "UserName";
client.ClientCredentials.UserName.Password = "Password";
var result = client.CallWebServiceMethod();
}
What should I do with iis to enable it?
See: http://technet.microsoft.com/nl-nl/library/cc733010(WS.10).aspx or build your own custom httpmodule, I use this one: http://custombasicauth.codeplex.com/, works perfect.