Solved

Moving code to App_Code

Posted on 2012-12-21
1
433 Views
Last Modified: 2012-12-25
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
Comment
Question by:Mazzarino
1 Comment
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now