Avatar of forsters
forsters
Flag for United Kingdom of Great Britain and Northern Ireland asked on

The directory '/SiteName/App_Code/' is not allowed because the application is precompiled.

Hi Experts,

Just been following a tutorial to add a stored proceedure to my site.

The steps involved adding an App_Code folder to store my new class in, but because the site is precompiled I seem to be unable to do this, is there a way round?  

I'm using VS2010 .net 4.0 if that has any bearing on things...
ASP.NET

Avatar of undefined
Last Comment
forsters

8/22/2022 - Mon
SOLUTION
lojk

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
forsters

ASKER
Hi Lojk,

Ok thanks for this, i'd just been reading a forum where someone had same problem, he was advised to copy site to server (host) rather than publish, the copy Web Site option does still exist is VS2010 I just didn't know about it until now.

So forgive my ignorance but your next comment is interesting because i'm relatively new to VS having moved over from DW.

In an ideal world I want to have my site in VS and Ctrl f5 to check and view my changes then when i'm ready publish/copy the bits I want to the server but be able to keep adding to and changing the site in this way. Is that approach good practice...it's what i'm used to...not sure how else to set things up?

Can you explain further your comment about having a multi-tier configuration, i'd like to understand this more because I keep coming across it but no idea how to begin setting a site up in this way...I'm still getting used to having code-behind and master pages, but i'd really love to get a handle on the bigger picture.

Many thanks an insight would be really appreciated
SOLUTION
lojk

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
forsters

ASKER
Umm, kinda.

I get the logic, just don't know how to set up a web App with this structure...for example where you say that you have a 'toolbox' project in all your sites - what I don't understand is how you do that..what is it, one page, several pages, is it a file, whats the filetype or does that vary? where is is, is it physically in your site or is it a seperate project that you call from your site?

This is the first time I've had to use a class so unchartered territory altogether, until now all my connection strings have lived in my web.config and I used SqlDataSource on my aspx page with a few bits and bobs in code behind for a button-click events etc, nothing much more complex than that so i'm not really clear on how all these 'layers' fit together or where they live in relation to the UI part of the site and each other...but I do see the point of them.

We've strayed off-piste somewhat but if you have time to point me in the right direction i'm interested and would be glad of the insight...points of-course are yours.
SOLUTION
lojk

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
forsters

ASKER
Thanks for screen shot, i'm really none the wiser as i'm sure you know so thanks i've clearly got a long-way to go before that makes sense but getting back to the original problem of My precompiled site not liking my new addition of an App_code folder, containing one class - in  a namespace, how do I resolve?

If I remove the App_code folder as suggested and put my class elsewhere, the reference to my namespace / class isn't found...
Your help has saved me hundreds of hours of internet surfing.
fblack61
SOLUTION
lojk

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
forsters

ASKER
Well I think thats what I have...

So I have the 3 pages:-
class file (.cs) now living in same folder as my .aspx page and it's .aspx.cs code behind page

My class file has:

namespace MyNameSpace
{
public class StoredProcedures
{
and so on...

My code behind page is calling my class file as follows:

...
using MyNameSpace;


public partial class MyFolder_MySubFolder_MyPage : System.Web.UI.Page
{
   

protected void Page_Load(object sender, EventArgs e)
{
    Repeater1.DataSource = StoredProcedures.MyStoredProcedureName();
        Repeater1.DataBind();

etc...
(the Repeater is obviously sitting in my .aspx page ready for action) but on the code behind the namespace is underlined 'could not be found' and so consequently the class 'StoredProcedures' is too

am I being daft, i've assumed that as the namespace is of my own making there are no prefixes to it's name because it's not a System.Web.OtherStuff.MyNameSpace, it's just MyNameSpace.. right??

Or is there something else I need to do, tried adding it to my web.config:

 <system.web>
        <pages>
            <namespaces>
                <add namespace="MyNameSpace"/>
            </namespaces>
etc..

 but it didn't like that either...

Thanks for your help with this, appreciating your patience
ASKER CERTIFIED SOLUTION
lojk

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
lojk

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
forsters

ASKER
It's not seeming to play ball.

Out of interest when you say look at the project properties, I am just using view - properties then highlighting my site root folder - is this correct? It was set up as a website not a project if that has any bearing...

No evidence of a 'default namespace' box that I can see?

Have tried using the sitename as a precursor to my namespace but my sqiggly red line just moves from under the namespace name to under the sitename.

When I try using intellisense (thanks for tip there) I get a few namespace options {System, ASP, AjaxControlToolkit, Microsoft, MS} but nothing more 'local' feel like I've missed something fundamental here...
SOLUTION
lojk

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
forsters

ASKER
Yeh I did think we might not quite be on the same hymn sheet...I should have checked sooner, sorry - it's been interesting though, so do you built websites as 'new project' rather than 'new web site'?

Irritatingly that 'allow changes to this precompiled site ' tickbox has been ticked all along so not sure why i'm having such issues with this app-code folder but it just wont have it.
Might just go to plan b and start a new site - think it'll be simpler that battling with the peculiarities of VS.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
lojk

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
lojk

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
forsters

ASKER
Thanks, I'll do that, and thanks for the post...will have a read now.

Well, I got round the namespace issue by getting rid of it altogether and putting my class in my code-behind so that they we're on one page and knew who each other were (think I've just gone against everything you've been saying but for the sake of everyones sanity i'm willing to gloss over that if you are...just this once).

after all that my stored proceedure doesn't work anyway - not suprised as never built one of those before either ( https://www.experts-exchange.com/questions/27622780/ASP-NET-QUERY-MULTIPLE-DATABASES.html how's your SQL)? so back to the drawing board but thanks for all you help working through this - you've kept me sane at least and I'll be giving the 'new project' button a click pretty soon...sounds like the way to go.
lojk

Great, glad you got it working, nearly suggested that but didn't for the reason you said ;-)

Am on holiday atm but will skim the new q and help if it hasn't already been sorted.

In development, every day is a school day - you have nothing to lose by trying something new - its fun, I promise!
forsters

ASKER
Great would be glad of some help but don't feel obliged, just asked the moderators to take a look as it's ground to a halt...

Can't believe you're doing this on your holiday!

But thanks, appreciated :O)
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck