将 asmx Web 服务的访问限制为特定 IP 地址
我需要将对 .asmx Web 服务的访问限制为特定 IP 地址。 我想我可以在每个方法中添加硬编码检查,但这似乎是代码维护的噩梦。 是否有可以创建的 Web 配置条目,或者可以应用于 .asmx 文件的 IIS 6 设置?
I need to limit access of an .asmx web service to specific IP addresses. I figure I could add a hardcoded check into each method, but that seems like a code maintenance nightmare. Is there a web configuration entry I can make, or a IIS 6 setting I can apply to the .asmx file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 IIS 6.0 管理器中,右键单击 .asmx 文件。
转到“文件安全”选项卡,然后单击“IP 地址和域名限制”中的“编辑”按钮。
单击“拒绝访问”单选按钮,然后将列入白名单的 IP 地址添加到列表中。
对于 IIS 7.5,这有点棘手,因为该文件不会显示在导航面板中。 您需要转到“内容视图”选项卡(位于窗口的下部),右键单击您的文件并选择“切换到功能视图”。 打开IP地址和域限制,单击编辑功能设置并选择拒绝未指定的主机。 现在您可以通过单击添加允许条目来添加授权。
In IIS 6.0 Manager, right click on the .asmx file.
Go to the File Security tab, and Click the Edit button in the IP Address and domain name restrictions.
Click the 'Denied Access' radio button, then add your whitelisted ip addresses to the list.
For IIS 7.5, it's a little tricky as the file doesn't show in the navigation panel. You need to go to the Content View tab (in the lower part of the window), right click on your file and choose Switch to Features View. Open IP Address and Domain Restriction, click on Edit Feature Settings and choose to deny unspecified hosts. Now you can add authorizations by clicking on Add Allow Entry.
将自定义部分添加到 web.config,然后查询该部分的 IP 地址白名单。
Add a custom section to your web.config, and then query that section for the whitelist of IP addresses.