Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Shared and object References

Reply
Thread Tools

Shared and object References

 
 
tshad
Guest
Posts: n/a
 
      01-09-2006
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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?=
Guest
Posts: n/a
 
      01-09-2006
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
>
>
>

 
Reply With Quote
 
 
 
 
tshad
Guest
Posts: n/a
 
      01-09-2006
"Sergey Poberezovskiy" <(E-Mail Removed)> wrote
in message news:(E-Mail Removed)...
> 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
> >
> >
> >



 
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
Replace all references to one object with references to other Jack Bates Python 3 08-06-2011 12:57 AM
Difference between bin and obj directories and difference between project references and dll references jakk ASP .Net 4 03-22-2005 09:23 PM
how to understand references to variables and references to constants are distinguished? baumann.Pan@gmail.com C++ 3 11-10-2004 04:16 AM
Pointers and References (and References to Pointers) Roger Leigh C++ 8 11-17-2003 10:14 AM
built with --enable-shared but get error: libpython2.3.so.1.0: can't open shared object file Douglass Turner Python 2 09-04-2003 01:56 PM



Advertisments