Re: HttpContext.Current returns null

Tech-Archive recommends: Fix windows errors by optimizing your registry



Nicholas,
How do I add a COM interop assembly to my project for "Microsoft Active
Server Pages Object", as you've stated? Just to clarify the program again. I
need to access IIS intrinstic objects from within a C# assembly which has
been instantiated by a VB 6 DLL.

Thanks,
-G


"Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:39048AB9-6965-4713-84E5-3414FF324817@xxxxxxxxxxxxxxxx
Gilgamesh,

Your assumption about the object context not being passed from the VB
dll to the C# dll is incorrect. In ASP.NET, it doesn't know anything
about the HttpContext class, so it's natural that the static Current
property returns null.

Rather, you will have to get the ASP intrinsic objects from COM+.

To do this, you will have to add a COM interop assembly to your project
for "Microsoft Active Server Pages Object". You will also have to set a
reference to System.EnterpriseServices.dll in your project.

Once you do that, when you need to access one of the intrisic object,
you will use the ContextUtils class in the System.EnterpriseServices
namespace. From there, you can call the GetNamedProperty method, passing
"Request", "Response", "Session", "Application", or "Server" to get the
appropriate intrinsic object. Cast the return value to the appropriate
interface type in the type library you created the interop assembly for,
and you should be able to use the ASP intrinsic object from there.

For more information on how to do this in VB6, see the following
article:

http://www.stardeveloper.com/articles/display.html?article=2000041401&page=1

This points out how you do it in VB6. The ContextUtil class in .NET
will handle the interaction with the ObjectContext, you just have to cast
it to the right return value.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Gilgamesh" <gilgamesh4ever@xxxxxxx> wrote in message
news:uv398jwIIHA.4272@xxxxxxxxxxxxxxxxxxxxxxx
We have a legacy ASP application which is calling a VB 6 DLL. This dll
then calls a C# dll assembly written in .net 2.0. We need to access
httpcontext in C# in order to get the request object associated with the
ASP page which initiated the request. HttpContext.Current retunes null in
C#, which indicates that the object context is not being passed from vb
dll to C# dll. Any idea why is this happening?

Thanks,
Gilgamesh





.



Relevant Pages

  • Re: HttpContext.Current returns null
    ... Your assumption about the object context not being passed from the VB ... dll to the C# dll is incorrect. ... you will have to get the ASP intrinsic objects from COM+. ... you should be able to use the ASP intrinsic object from there. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: HttpContext.Current returns null
    ... Your assumption about the object context not being passed from the VB dll to the C# dll is incorrect. ... you will have to get the ASP intrinsic objects from COM+. ... Cast the return value to the appropriate interface type in the type library you created the interop assembly for, and you should be able to use the ASP intrinsic object from there. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Deploying over IIS and VB
    ... >> I have Cobol Dlls written in Net Express Cobol and precompiled using ... >> VB dll is compiled as apartment threaded, ... > COM server in its own right, but is simply called from the VB COM ... > the object context it is running in). ...
    (comp.lang.cobol)
  • Many, many thanks
    ... Assuming that you instantiate the object in the dll on a .asp page, ... if you want to keep a dll loaded in IIS you have a couple ... my ole server dll was exposed. ...
    (microsoft.public.inetserver.iis)
  • Re: Please help
    ... Unable to open the Server service. ... DLL files to display messages from a remote computer. ... The NVIDIA Driver Helper Service service hung on starting. ... have the necessary registry information or message DLL ...
    (microsoft.public.windowsxp.perform_maintain)