简体   繁体   中英

How to restrict access to web service using login password using iis

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?

请参阅: http ://technet.microsoft.com/nl-nl/library/cc733010(WS.10) .aspx或构建您自己的自定义httpmodule,我使用这个: http ://custombasicauth.codeplex.com/,工作原理完善。

这是一个有用的链接Web服务安全性

最简单的解决方案是禁用网站的Anonymous Acces,然后为每个客户端创建Windows帐户。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM