473,324 Members | 2,313 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,324 software developers and data experts.

Shared and object References

I am trying to build a small shared routine that I call in all my pages. I
don't want to create an object reference as I just want to make a routine
that I can use to add in code that needs to be executed at the beginning of
all my pages with having to go change all the pages whenever this is needed.

Here is the routine I am setting up:
************************************************** *********
Imports System
Imports System.Web
Imports System.IO
Imports System.Web.UI
Imports System.Web.SessionState
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.HttpCookie
Imports System.Web.HttpCookieCollection
Imports System.Web.HttpResponse
Imports System.Web.HttpRequest
imports System.Web.HttpContext
Imports System.Web.HttpApplication
Imports System.Web.HttpApplicationState
Imports System.Collections
Imports FtsData

NameSpace MyFunctions

Public Class PageLoad

Public Shared sub InitialPageLoad ()

HttpContext.Current.Session("User").LastPageVisite d =
System.Web.HttpContext.Request.ServerVariables("PA TH_INFO")

end sub

End Class
End Namespace
************************************************** **************************
*******

but I am getting an error on the System.Web.HttpContext.Request:

C:\Inetpub\wwwroot\staffingworkshop\Classes\PageLo ad.vb(26) : error BC30469:
Reference to a non-shared member requires an object reference.

I just want to get the server variable Path_Info to get the current page.

How can I do this without setting up an object reference?

Thanks,

Tom
Jan 9 '06 #1
2 1646
Try:

Dim context As HttpContext = HttpContext.Current
If Not context Is Nothing Then
context .Session("User").LastPageVisited =
context.Request.ServerVariables("PATH_INFO")
End If

There is no Shared Request property of HttpContext object...

"tshad" wrote:
I am trying to build a small shared routine that I call in all my pages. I
don't want to create an object reference as I just want to make a routine
that I can use to add in code that needs to be executed at the beginning of
all my pages with having to go change all the pages whenever this is needed.

Here is the routine I am setting up:
************************************************** *********
Imports System
Imports System.Web
Imports System.IO
Imports System.Web.UI
Imports System.Web.SessionState
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.HttpCookie
Imports System.Web.HttpCookieCollection
Imports System.Web.HttpResponse
Imports System.Web.HttpRequest
imports System.Web.HttpContext
Imports System.Web.HttpApplication
Imports System.Web.HttpApplicationState
Imports System.Collections
Imports FtsData

NameSpace MyFunctions

Public Class PageLoad

Public Shared sub InitialPageLoad ()

HttpContext.Current.Session("User").LastPageVisite d =
System.Web.HttpContext.Request.ServerVariables("PA TH_INFO")

end sub

End Class
End Namespace
************************************************** **************************
*******

but I am getting an error on the System.Web.HttpContext.Request:

C:\Inetpub\wwwroot\staffingworkshop\Classes\PageLo ad.vb(26) : error BC30469:
Reference to a non-shared member requires an object reference.

I just want to get the server variable Path_Info to get the current page.

How can I do this without setting up an object reference?

Thanks,

Tom

Jan 9 '06 #2
"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.com> wrote
in message news:E1**********************************@microsof t.com...
Try:

Dim context As HttpContext = HttpContext.Current
If Not context Is Nothing Then
context .Session("User").LastPageVisited =
context.Request.ServerVariables("PATH_INFO")
End If

There is no Shared Request property of HttpContext object...
Oh.

I thought it was compaining that my InitialPageLoad was shared and needed to
be an object.

But you're saying I just have to create an object context inside my shared
routine.

I'll try that.

Thanks,

Tom
"tshad" wrote:
I am trying to build a small shared routine that I call in all my pages. I don't want to create an object reference as I just want to make a routine that I can use to add in code that needs to be executed at the beginning of all my pages with having to go change all the pages whenever this is needed.
Here is the routine I am setting up:
************************************************** *********
Imports System
Imports System.Web
Imports System.IO
Imports System.Web.UI
Imports System.Web.SessionState
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.HttpCookie
Imports System.Web.HttpCookieCollection
Imports System.Web.HttpResponse
Imports System.Web.HttpRequest
imports System.Web.HttpContext
Imports System.Web.HttpApplication
Imports System.Web.HttpApplicationState
Imports System.Collections
Imports FtsData

NameSpace MyFunctions

Public Class PageLoad

Public Shared sub InitialPageLoad ()

HttpContext.Current.Session("User").LastPageVisite d =
System.Web.HttpContext.Request.ServerVariables("PA TH_INFO")

end sub

End Class
End Namespace
************************************************** ************************** *******

but I am getting an error on the System.Web.HttpContext.Request:

C:\Inetpub\wwwroot\staffingworkshop\Classes\PageLo ad.vb(26) : error BC30469: Reference to a non-shared member requires an object reference.

I just want to get the server variable Path_Info to get the current page.
How can I do this without setting up an object reference?

Thanks,

Tom

Jan 9 '06 #3

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

Similar topics

0
by: Nick Marden | last post by:
I am trying to use threads::shared to make a thread-safe object. It appears to be the case that copying a blessed-then-shared reference to another shared variable keeps the underlying structure...
6
by: Paul | last post by:
Hi. Just trying to find out the best approach as I beleive it might give me problems later on down the road. I have an ASP.NET application which references a shared database class which...
11
by: Michael Schuler | last post by:
The use of STL in shared memory poses a real problem since (non-smart) pointers are not allowed there. Is there any solution for containers in shared memory using smart pointers? Where can I...
1
by: Dan | last post by:
Here's a scenario I'd like to discuss in order to setup my VS.NET IDE properly and be able to prepare a distribution: a) I have a windows forms C# app using 3 shared assemblies I developed to...
9
by: Invalidlastname | last post by:
Hi, We developed some assemblies which use EnterpriseServices queued components. In order to use EnterpriseServices, these assemblies need to be installed into GAC. I used the pre-build and...
6
by: Ross | last post by:
MyWebProject.MyWebForm1.someset.somedata is a datatable within a dataset. Displays quite nicely, too. Now I want to use the same data in MyWebProject.MyWebForm2. Being a old, er, experienced Java...
11
by: tshad | last post by:
I am setting up some of my functions in a class called MyFunctions. I am not clear as to the best time to set a function as Shared and when not to. For example, I have the following bit...
13
by: Nak | last post by:
Hi there, In VB6 if I wanted to make a shared application so to speak I would create an ActiveX EXE. This would allow me to expose objects of the application but only have 1 instance loaded. ...
5
by: Simon | last post by:
Hi all, We have an ASP.NET 1.1 application running on IIS6 on Server 2003. Most of the base objects we are using in this application are taken from a windows application also written by us. We...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.