ASP.NET功能用于生成会话ID? [英] Function ASP.NET uses to generate Session ID?
本文介绍了ASP.NET功能用于生成会话ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ASP.NET是否暴露它用来生成会话ID的基本功能?我想生成一个Web服务使用一个会话令牌,但它不会被放在的Set-Cookie头。如果ASP.NET已经具有的功能,我可以用它来生成一个会话ID这将节省我不必推出自己的。
Does ASP.NET expose the underlying function it uses to generate session IDs? I want to generate a session token for use in a web service, but it will not be put in the Set-Cookie header. If ASP.NET already has a function I can use to generate a session ID this will save me from having to roll my own.
推荐答案
反射是您的朋友:
SessionIDManager.CreateSessionID()
SessionIDManager.CreateSessionID()
internal static string Create(ref RandomNumberGenerator randgen)
{
if (randgen == null)
{
randgen = new RNGCryptoServiceProvider();
}
byte[] data = new byte[15];
randgen.GetBytes(data);
return Encode(data);
}
这篇关于ASP.NET功能用于生成会话ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文