我需要使用 PHP 访问在 C# 的 FormsAuthentication 方法中加密的 cookie,显然是在 System.Web.Security 中找到的。由于我在尝试将 Forms.Authentication.decrypt 移植到 PHP 解决方案时失败了,我现在转而使用 Mono 编写一个小型控制台应用程序来将加密的 cookie 传递给 Forms.Authentication.decrypt 但我收到了这个错误:
类型或命名空间名称
Security' does not exist in the namespace
System.Web'。您是否缺少程序集参考?
这是代码:
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Security.FormsAuthenticationTicket;
namespace Cookie
{
public class CookieDecrypt
{
public static void Main(string[] args)
{
if (args.Length == 0)
{
throw new System.ArgumentException("Please invoke like: mono CookieDecrypt.exe CookieString", "args");
}
string CookieValue = args[0];
FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(CookieValue);
Console.WriteLine(authTicket.Expired);
}
}
}
}
我在/usr/lib/mono/2.0/中看到了一些 .dll,例如System.Security.dll,但没有看到 System.Web.Security.dll,尽管http://docs.go-mono.com表明它可用(搜索forms.authentication encrypt 产生了几个结果,包括一个说FormsAuthentication Class (System.Web.Security.FormsAuthentication)的结果。
我是这样编译的:mcs test.cs
正如您无疑知道的那样,我是 c# 和 mono(几个小时前安装)的新手。谁能帮助我了解正在发生的事情以及如何解决它?