我完全同意@cassandrad!
但是,如果你要訪問它作爲純文本,比你必須提供自己實現TicketDataFormat
在CookieAuthenticationOptions
public class CustomAccessTokenFormat : ISecureDataFormat<AuthenticationTicket>
{
// If you want to do custom serialization and encryption
public string Protect(AuthenticationTicket ticket)
{
return "UserName|Role1|Role2|..."; // your raw text serialization goes here
}
// Deserilaize and decrypt the ticket
public AuthenticationTicket Unprotect(string strTicket)
{
return new AuthenticationTicket(null, null); // deserialize the plain text here into an AuthenticationTicket object
}
}
請首先描述您的實際目標和重寫你的問題,因爲它看起來像你正試圖做一些奇怪的事情,根據你的評論, – cassandrad
謝謝!更新我的問題更清晰 –