• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 487
  • Last Modified:

Moving code to App_Code

In a web application I have a page Page21.aspx which has code associated with it in Page21.aspx.vb. This code works fine so long a it is on Page21.aspx.vb.

I need to put in similar pages Page22.aspx, Page23.aspx etc. Rather than copy all the vba each time, I modified the code on Page21.aspx.vb to call up the common vba routines which I have now placed in App_Code.

Now I see some problems. In particular the system does not like "cache". I often use instructions like cache("jobbo")=nr to pass number from one part of the code to another. While this was OK on Page21.aspx.vb, it seems to think that cache is somehow ambiguous when in App_code:

Error      17      'Cache' is ambiguous, imported from the namespaces or types 'System.Web.HttpContext, System.Web.HttpResponse'.

The second immediate problem is that response.redirect("PageG300.aspx") shows response as "non-shared member requires an object reference". Why ? And what reference should I give ?

There is something about App_Code that I have missed. I seem as though I haven't declared something, but I don't understand what, and I'm not sure where to look.
0
Mazzarino
Asked:
Mazzarino
1 Solution
 
käµfm³d 👽Commented:
it seems to think that cache is somehow ambiguous when in App_code:
Then simply fully-qualify your usages of the term "Cache" in your code.

e.g.

System.Web.HttpContext.cache("jobbo")=nr

Open in new window


The second immediate problem is that response.redirect("PageG300.aspx") shows response as "non-shared member requires an object reference". Why ? And what reference should I give ?
Same thing:  Fully qualify any references to that class.
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now