WHAT DOES THE LINE <%@ PAGE ASPCOMPAT=TRUE %> ACTUALLY DO?

Amit Singh

Total Post:565

Points:2825
Posted by  Amit Singh
VB.Net 
 1856  View(s)
Ratings:
Rate this:
  1. Amit Singh

    Post:565

    Points:2825
    What does the line <%@ page aspcompat=true %> actually do?

    ASP used an STA based thread-pool optimized for apartment-threaded components. This thread-pool was managed by MTS -- which is how/why ObjectContext could be flowed to components on a page.

    ASP.NET by default uses an MTA based thread-pool (enables us to do async io completions, etc). For performance reasons, we don't by default attempt to surface the old ASP COM classic intrinsics via ObjectContext. Instead, components can directly get access to the intrinsics using the HttpContext.Current static property.

     For example:
    Dim Request as HttpRequest
    Dim Response as HttpResponse

    Request = HttpContext.Current.Request
    Response = HttpContext.Current.Response

    Enabling the <%@ page aspcompat=true %> switch at the top of the page does two things:

    1) Causes that page to be executed on an STA thread-pool instead of the new MTA one. This optimizes performance for VB6 created apartment threaded components.

    2) Causes us to surface the old ASP COM Intrinsics via ObjectContext. This will enable existing COM components built against the old ASP typelibraries to continue to work (note that if you want to get access to the new ASP.NET intrinsics -- you need to write code like the ones above).

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!