473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Get Server variables from within a COM

Hi

I've a web application written in ASP.Net. I'm calling a COM component from
it. Is there any way I can get the Server variables or Session variables of
that web application from within this COM.

Regards

Usman
Jun 17 '06 #1
2 1131

"Usman" <us***@advcomm.net> wrote in message
news:uE**************@TK2MSFTNGP05.phx.gbl...
Hi

I've a web application written in ASP.Net. I'm calling a COM component
from
it. Is there any way I can get the Server variables or Session variables
of
that web application from within this COM.
Sure,

You need to set AspCompat="true" as page tag in your asp.net page.

Further on, you just implement the IObjectControl interface in your
component...
make this a member variable!
CComPtr<ISessionObject> m_piSession;
//Active implementation from IObjectControl

STDMETHOD yourclass:Activate()
{
hr = CoGetObjectContext(IID_IObjectContext, (void**)&m_piObjContext);

if (hr == S_OK)

{

CComQIPtr<IContextProperties> pProps(m_piObjContext);

CComVariant vitem;
hr = pProps->GetProperty(CComBSTR(L"Session"), &vitem);
if (hr == S_OK)

{

vitem.pdispVal->QueryInterface(&m_piSession);

vitem.Clear();

}

return hr;

}
Regards

Usman

Keep in mind that you cannot share .NET specific variables with a COM object
like the 'long' datatype, or .NET references to managed classes! The
limitation is existing because the classic ASP interop code simply has not
been written with .NET in mind.

--
compatible web farm Session replacement for Asp and Asp.Net
http://www.nieropwebconsult.nl/asp_session_manager.htm

Jun 18 '06 #2

"Egbert Nierop (MVP for IIS)" <eg***********@nospam.invalid> wrote in
message news:%2****************@TK2MSFTNGP04.phx.gbl...

"Usman" <us***@advcomm.net> wrote in message
news:uE**************@TK2MSFTNGP05.phx.gbl...
Hi

I've a web application written in ASP.Net. I'm calling a COM component
from
it. Is there any way I can get the Server variables or Session variables
of
that web application from within this COM.


Sure,

You need to set AspCompat="true" as page tag in your asp.net page.


Forgot to add that you need to register the component in a COM+ app. It can
be in-proc and don't be afraid that the performance (often made prejudice by
programmers) would suffer by COM+. Disable synchronization in that
component. It probably does not need extra wrappers for syncing since
ASP.NET already syncs.

Jun 19 '06 #3

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

Similar topics

7
by: jopek | last post by:
pardon the simple question I am just getting into ASP and i am having a bit of a problem. If I set variables in the Application_OnStart() in the global.asa which is run on the server and then...
13
by: Jeager | last post by:
Why is it, Microsoft manage to write operating systems and office applications with every bell and whistle facility known to man. Yet, even after years and years of development they still cannot...
5
by: masood.iqbal | last post by:
My simplistic mind tells me that having local variables within looping constructs is a bad idea. The reason is that these variables are created during the beginning of an iteration and deleted at...
1
by: Macca | last post by:
Hi, I am implemeting an asynchronous socket server in my app. There will be up to 30 clients sending data to the socket server. Within the socket server I will have a number of local variables...
3
by: vunet.us | last post by:
Hello, I am breaking my head running out of ideas about the best solution to my goal. I want to load some pages generated with the server (ASP) and assign their html results to JavaScript, so...
18
by: Thomas Lunsford | last post by:
I have inherited a set of asp pages that I now need to augment. In order to minimize changes to production code, I would like to make a "call" to an asp page from a new asp page. Existing code is...
4
by: evantay | last post by:
I'm using ASP.NET 2.0 with VS.NET 2005. I'm trying to access properties from my master pages within a page that inherits from that master page (a child page). However the values are always null....
7
by: David | last post by:
i think i just realized i'm an idiot. again. (not syntactically correct code... just pieces to illustrate) class StateObject { members like socket, receiveBuffer, receiveBufferSize,...
17
by: =?Utf-8?B?SmltIFJvZGdlcnM=?= | last post by:
I am trying to replace a huge chunck of code that currently I incorporate with an #Include directive. The program rarely has to flow through that code, so I thought it would be better if I used...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.