473,486 Members | 1,850 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Accessing intrisic asp.net objects (ie Application, Session) from an assembly

Hi Folks!

A few tips or pointers on this one would be appriciated.

Presently I'm working on a webproject, and I've decided to
create a class that acts as template for all pages on the
site. What all the pages do is inheirit from
MyTemplatePage instead of System.Web.UI.Page. That works
fine and everything. My problem actually stems from the
fact that the same class has to be used for dictating the
layout of Classic ASP pages (instead of SSI). I have
converted the class(es) into a Class Library and then
registered the resulting assembly in the GAC (Global
Assembly Cache) on the server.

This also works fine, EXCEPT I can't access the context of
the caller (aspx-page). I'm not looking for a solution
where I can access/manipulate with the session object of
classic asp-pages, but I would like to be able to handle
the Application, Session, Querystring object of the
aspx.page in the assembly.
Is that at all possible? And how is it done?

I've tried the abvious, just adding a reference to the
system.web assembly
from the project, and then just trying this:

<Code>
public class MyTempPage : System.Web.UI.Page
{
private Boolean p_ContextGetEnabled;
public MyTempPage()
{
try
{
if (Application["objMenu"] == null)
{
MyMenuClass objMenu = new MyMenuClass();
Application.Add("objMenu", objMenu);
if (((MyMenuClass)Application
["objMenu"]).TestFunc() //Returns true when called
p_ContextGetEnabled = true;
else
p_ContextGetEnabled = false;
}
}
catch(Exception excep)
{
p_ContextGetEnabled = false;
}
}

public Boolean ContextGetEnabled
{
get {return p_ContextGetEnabled;}
}
....
....
.... //And so it continues.
</Code>

The ContextGetEnabled function ALWAYS returns false :o/
Any help would be very much appricated.

Thanks in advance.
JR Johansen

Nov 17 '05 #1
1 1318
Hello,
Please see if the following KB Article helps:

810928 HOW TO: Access ASP.NET Intrinsic Objects from .NET Components by Using
http://support.microsoft.com/?id=810928

Thanks.

Sincerely,
Sachin Goregaoker

Microsoft Developer Support

This posting is provided "AS IS" with no warranties,
and confers no rights.
|
| Hi Folks!
|
| A few tips or pointers on this one would be appriciated.
|
| Presently I'm working on a webproject, and I've decided to
| create a class that acts as template for all pages on the
| site. What all the pages do is inheirit from
| MyTemplatePage instead of System.Web.UI.Page. That works
| fine and everything. My problem actually stems from the
| fact that the same class has to be used for dictating the
| layout of Classic ASP pages (instead of SSI). I have
| converted the class(es) into a Class Library and then
| registered the resulting assembly in the GAC (Global
| Assembly Cache) on the server.
|
| This also works fine, EXCEPT I can't access the context of
| the caller (aspx-page). I'm not looking for a solution
| where I can access/manipulate with the session object of
| classic asp-pages, but I would like to be able to handle
| the Application, Session, Querystring object of the
| aspx.page in the assembly.
| Is that at all possible? And how is it done?
|
| I've tried the abvious, just adding a reference to the
| system.web assembly
| from the project, and then just trying this:
|
| <Code>
| public class MyTempPage : System.Web.UI.Page
| {
| private Boolean p_ContextGetEnabled;
| public MyTempPage()
| {
| try
| {
| if (Application["objMenu"] == null)
| {
| MyMenuClass objMenu = new MyMenuClass();
| Application.Add("objMenu", objMenu);
| if (((MyMenuClass)Application
| ["objMenu"]).TestFunc() //Returns true when called
| p_ContextGetEnabled = true;
| else
| p_ContextGetEnabled = false;
| }
| }
| catch(Exception excep)
| {
| p_ContextGetEnabled = false;
| }
| }
|
| public Boolean ContextGetEnabled
| {
| get {return p_ContextGetEnabled;}
| }
| ...
| ...
| ... //And so it continues.
| </Code>
|
| The ContextGetEnabled function ALWAYS returns false :o/
| Any help would be very much appricated.
|
| Thanks in advance.
| JR Johansen
|
|
Nov 17 '05 #2

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

Similar topics

2
2010
by: college | last post by:
I am trying to pass an array of user objects in session and take the array out of session and call the member functions of each object. However I am getting a Fatal error: Call to a member function...
14
2580
by: mjkahn | last post by:
I've read (and read!) that you shouldn't store objects in Session variables. I've read these reasons: - The object takes up memory that may not be freed until the session times out. Better to...
8
3159
by: Dave Wurtz | last post by:
All, I'm new to ASP development and I have a basic design question: Is it ok to store business objects to session variables or is there a better way to keep object information? For example,...
4
4124
by: Ralph Krausse | last post by:
ViewState = "Bill"; -- This statement will send that to the browser and hash it into the __VIEWSTATE hidden varible Application = "Bill"; -- This statement will keep this info on the server ...
3
1043
by: simon | last post by:
In global.asax.vb I have: Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) ' Fires when the application is started Application("OZN") = "HUF" End Sub But then on some the...
2
1792
by: Marlon R | last post by:
Is there a way to access COM object like VB.NET when Option Strict is set to Off. I am write an application that will interop with Excel. But the target machines all have different version...
4
1675
by: tshad | last post by:
Is there a way for a User Control to access an object (such as label or textbox) on the .aspx page that calls it? For example: x.aspx ************************************** .... Sub...
9
7274
by: david | last post by:
I have a class with some business-logic and with every roundtrip, I need an instance of this class, so I have to create it, every time again. That doesn't seem very efficient. I thought it would...
3
4111
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, is there another way to clear out Application Session variables besides doing an iisreset? Could you just reset the one application/virtual directory? thanks, rodchar
0
7123
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,...
1
6839
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7305
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4559
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
3066
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
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
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
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
259
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.