all groups > dotnet interop > march 2005 >
You're in the

dotnet interop

group:

Accessing Request.form within C# Class Library on Classic ASP Page



Accessing Request.form within C# Class Library on Classic ASP Page Mark Heimonen
3/30/2005 2:29:28 PM
dotnet interop: Hi, we have a large application framework written in ASP 3.0. We are
considering the possibility of moving some of our application logic over to
..NET by exposing c# classes through COM Interop. I was wondering if
somebody could walk us through the process of accessing the request.form and
request.querystring intrisic objects on our ASP 3.0 page from within our C#
class library. We have attempted several different techniques for acheiving
this goal, but have not found a succesful approach. Here are the methods we
have attempted:

#1. Using System.web.httpcontext.curren.request: This seemed the most
obvious, but we kept getting object not set to an instance of an object

#2. Looking at VB6 references, we attempted to emulate the process by using
Interop.ASPTypeLibrary.dll. This appears to be the correct approach, but we
could not find a method of directly instantiating the
ASPTypeLibrary.RequestClass object. It appears that this object needs to be
pulled from within an existing context.

#3. Next, we found this thread:
http://www.dotnet247.com/247reference/msgs/28/144525.aspx, which discusses
the same subject we were attempting. We are not familiar with
System.EnterpriseServices, but we attempted to get the process to work by
using the following code:

public string ReturnFormString()

{

ASPTypeLibrary.RequestClass myTest;

myTest =
(ASPTypeLibrary.RequestClass)System.EnterpriseServices.ContextUtil.GetNamedProperty("Request");

return myTest.QueryString["test"].ToString();

}

This, unfortunately, returned a specified cast is not valid. Can anybody
point us in the right direction?

Thanks,

Mark




Re: Accessing Request.form within C# Class Library on Classic ASP Page Mark Heimonen
4/11/2005 2:01:00 PM
After searching high and low, and doing quite a bit of research on COM+ and
System.EnterpriseServices, I finally found a solution to this issue, on the
GotDotNet Enterprise Services FAQ
(http://www.gotdotnet.com/team/xmlentsvcs/esfaq.aspx#13.1)

If you inherit your class from a serviced component, and reference asp.dll,
you can get access to the intrinsic ASP request and response objects.

Unfortunately, doing so causes performance to degrade, since the page will
execute in the STA.

In the end, we have decided to develop a serviced componentloop through the
request form and querystring, passing each item into our .NET .dll as a
string.

[quoted text, click to view]

AddThis Social Bookmark Button