By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,180 Members | 1,051 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,180 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.