【发布时间】:2011-04-01 00:15:38
【问题描述】:
我正在使用 ASP.NET MVC2,它从 Web 服务请求方法(我所有的 DAO 都放在 Web 服务中)。对于使用基本身份验证的 Web 服务。对于从 asp.net 到 web 服务的身份验证,我使用 FormsAuthentication。为此,我编写了从 MembershipProvider 继承的 WebServiceMembershipProvider。在 ValidateUser 方法中,我连接到 Web 服务,如果身份验证成功 - 使用 FormsAuthentication.SetAuthCookie 将票证保存在 cookie 中。
我的问题:验证后我必须在哪里存储用户名和密码:Cookies、Session 还是其他? 在调用凭据中的方法之前,我需要存储用户名和密码以将其发送到 Web 服务,例如:
MyServiceSoapClient client = new MyServiceSoapClient();
client.ClientCredentials.UserName.UserName = this.username;
client.ClientCredentials.UserName.Password = this.password;
List<Product> products = client.GetProductList();
【问题讨论】:
标签: c# authentication asp.net-mvc-2