Be Thread-Aware in ASP.NET

Be Thread-Aware in ASP.NET

Thread awareness is not an issue specific to managed code, but you should know about it anyway. ASP.NET uses a multithreaded apartment (MTA) thread pool. (All managed code components use MTA.) When you call a COM object marked as using a single-threaded apartment (STA), the Web application switches threads and loses the impersonation context. The way around this is by using AspCompatMode=true to run a page on an STA thread. This is the only supported scenario for using STA components from ASP.NET. You can also call CoImpersonateClient in your component if you rely on the behavior.

That said, you should not use STA components anyway they can be a huge performance drag on ASP.NET.

note

Visual Basic 6 COM components use STA.



Writing Secure Code
Writing Secure Code, Second Edition
ISBN: 0735617228
EAN: 2147483647
Year: 2005
Pages: 153

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net