c# – ASP.NET MVC 2和FormsAuthentication的Web服务身份验证
发布时间:2020-12-15 21:09:41 所属栏目:百科 来源:网络整理
导读:我正在使用ASP.NET MVC2,它从Web服务请求方法(我在Web服务中的所有DAO位置).对于使用基本身份验证的Web服务.对于从asp.net到web-service的身份验证,我使用FormsAuthentication.为此我写了一个来自MembershipProvider的WebServiceMembershipProvider继承.在方
我正在使用ASP.NET MVC2,它从Web服务请求方法(我在Web服务中的所有DAO位置).对于使用基本身份验证的Web服务.对于从asp.net到web-service的身份验证,我使用FormsAuthentication.为此我写了一个来自MembershipProvider的WebServiceMembershipProvider继承.在方法ValidateUser中,我连接到Web服务,如果验证成功 – 在cookie中保存票证使用FormsAuthentication.SetAuthCookie.
我的问题:验证后我必须存储用户名和密码:Cookies,会话还是其他? MyServiceSoapClient client = new MyServiceSoapClient(); client.ClientCredentials.UserName.UserName = this.username; client.ClientCredentials.UserName.Password = this.password; List<Product> products = client.GetProductList(); 解决方法
如果我正确理解了这个问题,那么你有一个web-app,它在调用之后调用一个需要用户名和密码的web服务,这也是一个函数调用.
在您的WebService类(WebServiceMembershipProvider)中,您从MembershipProvider继承并调用MembershipProvider.ValidateUser. If you are talking about storing more information then just that in FormsAuthentication.SetAuthCookie,then this is the answer you are probably looking for. Other wise this has a lot of example code for working with Forms Authentication in Webservices that might help you. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |