Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Accessing intrisic asp.net objects (ie Application, Session) from an assembly

Reply
Thread Tools

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

 
 
Johan Riis Johansen
Guest
Posts: n/a
 
      08-21-2003
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 /
Any help would be very much appricated.

Thanks in advance.
JR Johansen

 
Reply With Quote
 
 
 
 
Sachin Goregaoker
Guest
Posts: n/a
 
      08-25-2003
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 /
| Any help would be very much appricated.
|
| Thanks in advance.
| JR Johansen
|
|


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding assembly to windows\assembly through bat file Grant Merwitz ASP .Net 3 09-15-2005 11:40 AM
Assembly's manifest definition does not match the assembly reference. Horatiu Margavan via .NET 247 ASP .Net 0 08-30-2004 04:14 PM
ASP.NET 2.0: What is the namespace and assembly name of generated assembly SA ASP .Net 0 08-09-2004 05:09 PM
Referencing assembly from GAC using @assembly fails Brent ASP .Net 1 01-23-2004 08:23 PM
can a strongly named assembly reference a regular assembly? Prasanna Padmanabhan ASP .Net 1 11-19-2003 06:21 AM



Advertisments