C# C语言中基于Cookie的身份验证#
我有两个wpf应用程序的大问题 我们将服务器上的身份验证从基本http更改为基于cookie的身份验证,即令牌。这两个应用程序使用RestSharp使用旧的基本http身份验证对用户进行身份验证(一切正常):C# C语言中基于Cookie的身份验证#,c#,rest,authentication,cookies,restsharp,C#,Rest,Authentication,Cookies,Restsharp,我有两个wpf应用程序的大问题 我们将服务器上的身份验证从基本http更改为基于cookie的身份验证,即令牌。这两个应用程序使用RestSharp使用旧的基本http身份验证对用户进行身份验证(一切正常): 更改为基于cookie后,我们从服务器获取状态代码403。我已经读到restsharp可以使用cookies。如何通过令牌编辑代码并使用基于cookie的身份验证对用户进行身份验证?谢谢所以我添加了以下内容来解决这个问题: client.FollowRedirects = false; /
更改为基于cookie后,我们从服务器获取状态代码403。我已经读到restsharp可以使用cookies。如何通过令牌编辑代码并使用基于cookie的身份验证对用户进行身份验证?谢谢所以我添加了以下内容来解决这个问题:
client.FollowRedirects = false; // very important in my case
... request.addParameters ...
... client.execute(request) ...
if (response.StatusCode == HttpStatusCode.Found)
{
if (response.Cookies.Count == 1)
{
msg.Cookie = response.Cookies[0].Value;
msg.ReturnValue = true;
}
}
client.FollowRedirects = false; // very important in my case
... request.addParameters ...
... client.execute(request) ...
if (response.StatusCode == HttpStatusCode.Found)
{
if (response.Cookies.Count == 1)
{
msg.Cookie = response.Cookies[0].Value;
msg.ReturnValue = true;
}
}