如何通过用户名和密码保护C#webservice? [英] How to protect C# webservice through username and password?

查看:482
本文介绍了如何通过用户名和密码保护C#webservice?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我在框架3.5中创建了C#Web服务。服务正常,但任何客户都可以使用。我希望只有经过身份验证的用户才能访问Web服务。所以我必须通过用户名和密码来保护网络服务。那么我将如何为网络服务提供安全保障?



我尝试了什么:



我已尝试使用soap标头,但需要向client添加web引用。但我没有使用Web引用来使用Web服务。

Hello,
I have created C# web service in framework 3.5. Service works properly but it can be used by any client. I want the web service to be accessed by only authenticated user. So I have to protect web service through username and password.So how I shall provide security to web service?

What I have tried:

I have tried by soap header but it required to add web reference to client.But I didn't use web reference to consume web service.

推荐答案

如果它是WCF我相信你可以通过web.config做到这一点,而无需更改任何代码。否则,编写一些代码来进行身份验证。或者,在IIS中托管它并在那里设置身份验证。你有几个选择。
If it is WCF I believe you can do that through the web.config without any code changes. Otherwise, write some code to do the authentication. Or, host it in IIS and set the authentication there. You have several options.


这篇关于如何通过用户名和密码保护C#webservice?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆