Accessing the HTTP Request sent to legacy ASP page in .Net C# COM

O

omantawy

Hi,

I have some legacy ASP web applications that use an unmanaged COM
component to connect to a third party application. The third part
application has moved to the managed code in the current release with
backward compatibility with the unmanaged code.
In the future releases, the vendor is going to drop backward
compatibility and as a result of that all our legacy ASP applications
will break.

What I am trying to do is:
- Create a managed COM component using the InteropServices that wraps
the new managed components using C# that provides the same interfaces
like the vendors old unmanaged one.
- Use this component in the ASP application instead of the old one to
retrieve the necessary information from the new system and pass it back
to the ASP application.

Unfortunately, this requires accessing the HTTP request sent to the ASP
application from within the .Net component. When I tried to use the
..Net System.Web.HttpContext.Current.Request it gave me an exception
that "Object reference not set to an instance of an object".

My questions are:
- When using the managed COM in the legacy ASP, can I instantiate the
..Net http request within the same context of the unmanaged client?
- How can I construct a .Net http request from the ASP Request object?

Thanks,

Omar
 
J

John Timney \(MVP\)

- When using the managed COM in the legacy ASP, can I instantiate the
.Net http request within the same context of the unmanaged client?

I dont think you can intercept the request from .net, at least not with
managed code which is what you would be wrapping up via interop. Any
instance of .Net System.Web.HttpContext.Current.Request belongs to asp.net's
ISAPI handler which is not involved in your request transaction through asp,
so you'll probably have to create an unmanaged ISAPI and host it within IIS
to interecept any requests through asp. Theres a good range of utility
example apps here if you want to look into this:
http://www.genusa.com/isapi/isapisrc.html. That said, I'm not sure whether
you could create a cookie container in your asp wrapped COM that made use of
..NET webrequest to your own server to create an active session, sounds messy
to me!!
- How can I construct a .Net http request from the ASP Request object?

Interop this:
http://samples.gotdotnet.com/quicks...tart/howto/samples/net/ASPXNet/webrequest.src

Although I dont know how complex your asp code is and how many method
changes you would require, perhaps you need to approach the problem a
different way. Have you thought about wrapping the third party app
interfaces with a .NET webservice and access that from your asp code using
xmlhttp or SOAP and changing as little as possible without trying to
unstring spaghetti?

--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top