Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 来自ASP.NET MVC 2的Web服务身份验证和表单身份验证_C#_Authentication_Asp.net Mvc 2 - Fatal编程技术网

C# 来自ASP.NET MVC 2的Web服务身份验证和表单身份验证

C# 来自ASP.NET MVC 2的Web服务身份验证和表单身份验证,c#,authentication,asp.net-mvc-2,C#,Authentication,Asp.net Mvc 2,我正在使用ASP.NETMVC2,它从Web服务(我在Web服务中的所有DAO位置)请求方法。用于使用基本身份验证的Web服务。对于从asp.net到web服务的身份验证,我使用FormsAuthentication。为此,我从MembershipProvider编写了WebServiceMembershipProvider继承。在ValidateUser方法中,我连接到Web服务,如果身份验证成功,请使用FormsAuthentication.SetAuthCookie将票据保存在Cookie

我正在使用ASP.NETMVC2,它从Web服务(我在Web服务中的所有DAO位置)请求方法。用于使用基本身份验证的Web服务。对于从asp.net到web服务的身份验证,我使用FormsAuthentication。为此,我从MembershipProvider编写了WebServiceMembershipProvider继承。在ValidateUser方法中,我连接到Web服务,如果身份验证成功,请使用FormsAuthentication.SetAuthCookie将票据保存在Cookie中

我的问题:验证后我必须在哪里存储用户名和密码:Cookies、会话或其他? 我需要存储用户名和密码,以便在凭据中调用方法之前将其发送到Web服务,例如:

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

如果我正确理解了这个问题,那么您有一个web应用程序调用一个web服务,该web服务在身份验证后需要用户名和密码进行函数调用,这也是一个函数调用

在WebService类(WebServiceMembershipProvider)中,您从MembershipProvider继承并调用


我知道这个问题很老了,但我需要一个代表来亲自提出悬赏。我希望这至少对投票支持它的人有用。我们使用在FormsAuth cookie中存储额外信息的方法,通过序列化和反序列化将其输入和输出到UserData中。它对我们很有效,但我对将用户密码存储在其中(尽管它是加密的)持保留态度。