473,394 Members | 1,724 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,394 software developers and data experts.

trouble utilizing intrinsic objects in custom class

I'm trying to write/compile a class that (1) accesses all the intrinsic ASP.NET objects (2) Uses Server.Transfer to redirect a user back to a log in page if a session has expired. I've gotten inconsistent results. The redirection works perfectly if the user session has expired, but throws an exception if it hasn't. Both "ASPIntrinsicObjects" and "Miscfunctions" compile correctly without a hitch, but bomb out upon executio

I start with a Base class that grabs all the intrinsic objects called "ASPIntrinsicObjects". Code follows

Imports Syste
Imports System.We
Imports System.Web.SessionStat
Imports System.Web.UI.Pag

Public Class ASPIntrinsicObject
Private Shared objHttpContext As HttpContex
Private Shared objResponse As HttpRespons
Private Shared objRequest As HttpReques
Private Shared objApplication As HttpApplicationStat
Private Shared objSession As HttpSessionStat
Private Shared objServer as HttpServerUtilit

Shared Sub New(
'Get all intrinsic object
objHttpContext = HttpContext.Current(
objApplication = objHttpContext.Applicatio
objSession = objHttpContext.Current.Session(
objResponse = objHttpContext.Respons
objRequest = objHttpContext.Reques
objServer = objHttpContext.Serve
End Su

Public ReadOnly Shared Property Request() as HttpReques
Ge
Return objReques
End Ge
End Propert

Public ReadOnly Shared Property Response() as HttpRespons
Ge
Return objRespons
End Ge
End Propert

Public ReadOnly Shared Property Session() as HttpSessionStat
Ge
Return objSessio
End Ge
End Propert

Public ReadOnly Shared Property Application() as HttpApplicationStat
Ge
Return objApplicatio
End Ge
End Propert

Public ReadOnly Shared Property Server() as HttpServerUtilit
Ge
Return objServe
End Ge
End Propert

End Clas
---------------------------------------------------------------------
Then, I inherit it through another class called "SessionMonitor". This utilizes a shared method called "CheckForExpiredSession" to server.transfer if the session has expired. This is the method I call on in my asp.net page. Code Follows

Imports Syste
Imports System.We
Imports System.Exceptio
Imports ASPIntrinsicObject

NameSpace MiscFunction

Public Class SessionMonito

Public Shared Sub CheckForExpiredSession(
Tr
if Session("intCustID") is nothing the
Server.Transfer("default.aspx"
end i
catch exc as Exceptio
Throw new ApplicationException(exc.toString()
End Tr
End Su

End Clas

End NameSpac
-------------------------------

The code in my web form is

<%@ Page Language="VB" autoeventwireup="true" Debug="true" Trace="false" %><%@ import Namespace="MiscFunctions" %><%@ import Namespace="System.Data" %><%@ import Namespace="System.Data.SqlClient" %><script runat="server"
Sub Page_Load(Sender as Object, E as EventArgs
SessionMonitor.CheckForExpiredSession(
[more code]
End Su
</SCRIPT
'------------------------------------------------
The exception message is as follows

System.Web.HttpException: Error executing child request for default.aspx. ---> System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.HttpServerUtility.ExecuteInternal(Strin g path, TextWriter writer, Boolean preserveForm) --- End of inner exception stack trace --- at System.Web.HttpServerUtility.ExecuteInternal(Strin g path, TextWriter writer, Boolean preserveForm) at System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm) at System.Web.HttpServerUtility.Transfer(String path) at MiscFunctions.SessionMonitor.CheckForExpiredSessio n()

Nov 18 '05 #1
0 1004

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

Similar topics

1
by: Glenn Venzke | last post by:
I'm trying to write/compile a class that (1) accesses all the intrinsic ASP.NET objects (2) Uses Server.Transfer to redirect a user back to a log in page if a session has expired. I've gotten...
13
by: Alek Davis | last post by:
Hi, Is it possible to access intrinsic ASP objects, such as Request, from a .NET class. Say, I have a .NET library exposed via a COM or COM+ wrapper. Can this library retrieve the request info...
5
by: Alan Ho | last post by:
What are intrinsic objects of asp.net? thx
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
7
by: A Traveler | last post by:
Hello all, i was just curious if anyone whos been playing with VS2005 could tell me... In javascript (and java??) you can alter the prototypes for an object in your project. I dont remember...
0
by: albean | last post by:
I I have a number of VB COM components used in ASP pages that access some intrinsic ASP objects. Basically we would get the context from COMSVCSLib and from there get the ASP Request and Response...
2
by: jason | last post by:
hello everyone, i have had a suppot ticket open with microsoft for some time to investigate a memory leak issue we are experiencing on our production web servers. the web servers host both ASP...
8
by: Thelma Lubkin | last post by:
I have finally nagged more work out of the non-profit organization that I'm trying to do volunteer work for. The following code begins a tiny form that is part of the project that I'll be...
25
by: Penelope Dramas | last post by:
Hello, I'm in a front of very serious .net redesign/rewrite of an old VB6 application. I had been asked to make it .NET 2.0 and would like to ask couple of questions regarding data access as...
2
by: =?Utf-8?B?cHJhZHk=?= | last post by:
Hi, Is it possible for me to create new users without using the wizard? I am using a custom membership as i want to capture more data other than the ones which are available in the wizard. Is it...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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
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
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...

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.