开发者

Web-service authentication from ASP.NET MVC 2 and FormsAuthentication

I'm using ASP.NET MVC2 which request methods from Web-service (My all DAO place in Web-service). For Web-service using Basic Authentication. For authentication from asp.net to web-service, I use FormsAuthentication. For this I was write WebServiceMembershipProvider inheritance from MembershipProvider. In method ValidateUser I connect to Web-service and if authentication was successfully - save ticket in cookies use FormsAuthentication.SetAuthCookie.

My question: where I must store username and password after validation: Cookies, Session or other? I need stored username and password for send it to Web-service befor开发者_运维问答e call methods in Credentials, for example:

MyServiceSoapClient client = new MyServiceSoapClient();
client.ClientCredentials.UserName.UserName = this.username;
client.ClientCredentials.UserName.Password = this.password;
List<Product> products = client.GetProductList();


If I understand the question correctly, you have a web-app that calls a web service that needs a user name and a password for function calls after the authentication, which is also a function call.

In your WebService class (WebServiceMembershipProvider) you inherit from MembershipProvider and make a call to 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜