我需要使用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加密会出现几个结果,包括 FormsAuthentication类(System.Web.Security.FormsAuthentication)。
我正在编译:{{1}}
毫无疑问,我是c#和mono(几小时前安装)的新手。任何人都可以帮助我了解正在发生的事情以及如何解决这个问题吗?
答案 0 :(得分:1)
FormsAuthenticationTicket是一个类。 using
语句仅适用于名称空间。您需要的命名空间是System.Web.Security。但是,FormsAuthenticationTicket位于System.Web.dll程序集中。
.NET文档实际上非常明确地说明了哪些命名空间和哪些程序集类。示例:http://msdn.microsoft.com/en-us/library/system.web.security.formsauthenticationticket.aspx
如您所见,继承层次结构下的是程序集和命名空间。