OK, I think I figured it out. In case you need to do something similar try
to follow these steps:
(1) Add a reference to System.EnterpriseServices namespace (you need to add
a DLL along with using/Imports statement).
(2) Open project properties and add a reference to your SNK (key) file in
the Wrapper Assembly Key File under Wrapper Assembly ActiveX/COM Objects
heading (in General properties).
(3) Add a COM reference (using the middle tab of the Add Reference dialog)
to ASP.DLL. This DLL implements intrinsic ASP COM objects, such as Request,
Response, etc. It is supposed to be located under the
%WINDIR%\System32\inetsrv folder. When you complete this step VS.NET will
generate a proxy DLL called ASPTypeLibrary, sign it with the key from the
file you specified in step 2 and copy it to your project. You will use this
DLL to reference the intrinsic ASP COM objects. You will need to deploy this
DLL along with your app.
(4) Add a reference to the ASPTypeLibrary namespace (via using/Imports
statement).
(5) To access an intrinsic ASP COM object, call the
ContextUtil.GetNamedProperty method passing the name of the object you are
interested in, such as
// Request is defined in ASPTypeLibrary.
Request request = (Request)ContextUtil.GetNamedProperty("Request");
(6) Now you can use the Request object. It may be a bit tricky, though. For
example, this is how you retrieve the value of the REMOTE_HOST server
variable:
// Apparently, the array elements start with index 1, not 0.
string host =
((IStringList)request.ServerVariables["REMOTE_HOST"])[1].ToString();
For more info, check
http://www.gotdotnet.com/team/xmlentsvcs/esfaq.aspx#13.1 (it has a VB
version as well).
Alek
Alek Davis said:
Hi,
Is it possible to access intrinsic ASP objects, such as Request, from a ..NET
class. Say, I have a .NET library exposed via a COM or COM+ wrapper. Can
this library retrieve the request info (basically, server variables exposed
via the Request object), when it is invoked from a traditional ASP (not
ASP.NET) application? Any ideas? Thanks in advance.
Alek