Question

Using VS2008, I am trying to add an App_Code folder from add-->folder-->Add ASP_NET folder.

The App_Code folder option is there as expected BUT ... it's disabled!?

I am pretty sure I am working with a WebSite project (and not a Web Application) because I can add all the other ASP_NET folders (App_Data - App_themes etc) and also because I don't have the controls declarations in my-code behind (as opposed to Web Application where you have partial classes with controls declaration and eventHandlers etc.). Fact is, if it's not a website project how come I can add the other ASP_NET folders? And also - why I am not getting any designer file with controls declaration etc? This is the way things used to work in VS2005.

If I go ahead and add App_Code folder myself as a normal folder it picks-up the icon of the ASP_NET App_Code folder - so it seems to be working fine.

Still it's bugging me 'cause I can't understand why the opion is disabled in the first place.

Any clue why this is happening?

EDIT: I am trying to create a new web site and I get only the web application template so I doubt I was able to create a website in the first place. A bit confused here!

Was it helpful?

Solution

Are you sure it is web site project and not web application?

OTHER TIPS

No idea why it's happening, but you should be able to just add a new folder in the Solution Explorer and rename/call it App_Code.

Do this in Windows Explorer even, if you like.

Refresh and it'll pick it up.

You add a new folder to project. Then, rename it as App_Code. Visual studio could revise the folder as App_Code folder.

May be if you add .cs file, it will be created?

Did this option worked for you before? Did you do something before it stopped working?

There's really no such thing as a "web site project". Web sites are project-less, in that they don't contain a .csproj (or .vbproj) file in the folder. If you see this file, then it's a "web application" project. Also, if you're selecting from the menu "new project...", then you're not selecting a "web site".

The only way that you're using a web site, is by selecting "new web site" from the VS File menu.

You can only get to the App_Code new folder option in the New ASP.Net Folder drop down if you are working in a Website and not in a web application. Caught me out a few times too. Hope that this helps.

you can't add the App_Code folder to a Web Application because this folder is designed for runtime compilation by asp.net and the Web Application project is designed for you to precompile your website into a dll which you can find in the Bin folder and deploy to your site.

So, for Web App Projects, you should instead Add a folder called something like 'CodeFolder' and then add you class in there. Then right click properties on that class file and set its build config to compile rather than content.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top