简体   繁体   English

我需要清除Thread.CurrentPrincipal吗?

[英]Do I need to clear Thread.CurrentPrincipal?

When user is connecting to my webservice I will set the Thread.CurrentPrincipal (messageinspector) with my custom context and this can then be used thou out the entire solution. 当用户连接到我的Web服务时,我将使用自定义上下文设置Thread.CurrentPrincipal (messageinspector),然后就可以在整个解决方案中使用它。

The question is if this Thread.CurrentPrincipal needs to be set to null or is this only living during the current call? 问题是此Thread.CurrentPrincipal需要设置为null还是仅在当前调用期间存在?

It does seem to only last for the current call but Im not sure if that just a coincident? 它似乎只在当前通话中持续,但我不确定这是否只是一个巧合?

BestRegards 最好的祝福

没有巧合,当您的调用完成时当前线程完成并且您不再具有标识时,我发现了同样的情况。

This property represents your current security login and therefore should probably not be set to null unless you have a particular need to do so. 此属性表示您当前的安全性登录名,因此除非您有特殊需要,否则不应将其设置为null。 There are a number of situations where that would be appropriate (online banking, for example), but otherwise you will probably need it to continue accessing the resources you need to access. 在许多情况下,这是适当的(例如,在线银行),但否则,您可能需要它来继续访问需要访问的资源。

Further reading at the MSDN article: http://msdn.microsoft.com/en-us/library/system.threading.thread.currentprincipal.aspx 进一步阅读MSDN文章: http : //msdn.microsoft.com/en-us/library/system.threading.thread.currentprincipal.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM