简体   繁体   中英

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.

The question is if this Thread.CurrentPrincipal needs to be set to null or is this only living during the current call?

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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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