473,473 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to access the HttpContext.Current.Request in C++ .NET Class library

Hello,

I am working on a .NET C++ project based on the
"Class Library (.NET)" wizard of Visual Studio .NET 2003.

I would like to know if my .NET component is running
in a ASP.NET page (.apsx file), and if it is the case I would
like to execute a specific task based on the current
HTTP request.

I searched the Microsoft documentation but couldn't
find much information.

1) How can I know if my component is running in an
ASP.NET page?

2) If so, how can I access the current HTTP request?

I think that I must access object
"System.Web.HttpContext.Current.Request".
If this is correct, I have no idea how to do so
within my C++ .NET project?

All help would very appreciated. Thank you very much.

Phil Ten

Nov 16 '05 #1
2 6410
Hi.

First, you need to include a reference to System.Net.dll

This line would go into the stdafx.h file:
#include "System.Web.dll"

In you c++ file you would then write

using namespace System::Web;

in your method you would write
HttpContext *context = HttpContet::Current;
if ( context ) // remember to test if it's null
HttpRequest *request = context->Request;

"Phil Ten" <pt@dafweb.com> wrote in message
news:Oa**************@TK2MSFTNGP09.phx.gbl...
Hello,

I am working on a .NET C++ project based on the
"Class Library (.NET)" wizard of Visual Studio .NET 2003.

I would like to know if my .NET component is running
in a ASP.NET page (.apsx file), and if it is the case I would
like to execute a specific task based on the current
HTTP request.

I searched the Microsoft documentation but couldn't
find much information.

1) How can I know if my component is running in an
ASP.NET page?

2) If so, how can I access the current HTTP request?

I think that I must access object
"System.Web.HttpContext.Current.Request".
If this is correct, I have no idea how to do so
within my C++ .NET project?

All help would very appreciated. Thank you very much.

Phil Ten

Nov 16 '05 #2
Thank you very much Peter. I followed your instructions
and it worked perfectly :)

Phil Ten.
"Peter Strøiman" <blah@blahblahblah> wrote in message
news:uA**************@TK2MSFTNGP11.phx.gbl...
Hi.

First, you need to include a reference to System.Net.dll

This line would go into the stdafx.h file:
#include "System.Web.dll"

In you c++ file you would then write

using namespace System::Web;

in your method you would write
HttpContext *context = HttpContet::Current;
if ( context ) // remember to test if it's null
HttpRequest *request = context->Request;

"Phil Ten" <pt@dafweb.com> wrote in message
news:Oa**************@TK2MSFTNGP09.phx.gbl...
Hello,

I am working on a .NET C++ project based on the
"Class Library (.NET)" wizard of Visual Studio .NET 2003.

I would like to know if my .NET component is running
in a ASP.NET page (.apsx file), and if it is the case I would
like to execute a specific task based on the current
HTTP request.

I searched the Microsoft documentation but couldn't
find much information.

1) How can I know if my component is running in an
ASP.NET page?

2) If so, how can I access the current HTTP request?

I think that I must access object
"System.Web.HttpContext.Current.Request".
If this is correct, I have no idea how to do so
within my C++ .NET project?

All help would very appreciated. Thank you very much.

Phil Ten


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: julian | last post by:
I'm getting "'HttpContext' does not exist in the class or namespace 'System.Web'" from trying to build (with Microsoft Development Environment 2003, ver. 7.1.3088, .NET Framework 1.1, ver....
6
by: SteveS | last post by:
Hello All. I have an asp.net application with 3 different assemblies. They are like this: 1) Assembly: PublicSite (This contains the website UI) Root namespace: PublicSite 2) Assembly:...
2
by: Terry Mulvany | last post by:
namespace CIBWeb { public class BasePage : System.Web.UI.Page { public BasePage() { } protected override void OnInit(EventArgs e) {
1
by: josephpage | last post by:
I have a Visitor class that is defined in a class library. The class has lots of parameters that are pulled from the QueryString, the ReferrerUrl, Cookies, the Session object, etc... I would...
3
by: Steve Franks | last post by:
Is there a way I can extend the HttpContext or one of its subclasses to include a property that exposes a custom class of mine to all ASP.NET pages? More specifically, I'd like to use a...
1
by: GarDavis | last post by:
When the ASP.Net application ends, the Application_OnEnd() method in Global.asax is called. This method calls a utility in a class library to dump information about the ending application. The...
7
by: bhavin30 | last post by:
Is there a way to obtain user information (using LOGON_USER server variables) when you have set up the security to Anonymous Access? I have tried setting the security to both Anonymous + Window...
0
by: bharathreddy | last post by:
Here I will given an example on how to access the session, application and querystring variables in an .cs class file. Using System.Web.HttpContext class. 1) For accesing session variables :...
8
by: eric | last post by:
I have a 2.0 asp.net project. In a class contained within a seperate project, I am trying to reference HttpContext.Current.Session but Session is always null. I've tried implementing...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.