I am getting the following error when I put class files in subfolders of my App_Code folder:
errorCS0246: The type or namespace name 'MyClassName' could not be found (are you missing a using directive or an assembly reference?)
This class is not in a namespace at all. Any ideas?
You need to add codeSubDirectories to your compilation element in web.config
<configuration>
<system.web>
<compilation>
<codeSubDirectories>
<add directoryName="View"/>
</codeSubDirectories>
</compilation>
</system.web>
</configuration>
Check for BuildAction property of file. This should be set to "Compile"
Is it possible that you haven't set the folder as an application in IIS (or your web server)? If not, then the App_Code that gets used is that from the parent folder (or the next application upwards).
Ensure that the folder is marked as an application, and uses the correct version of ASP.NET.
It might not be the correct way but I find it the easiest.
Create the class in the main Folder as usual, then move it with your mouse to your sub-folder. Re-compile and all should be fine.
As you add folders to your app_code, they are getting separated by different namespaces, if I recall correctly, using the default namespace as the root, then adding for each folder.
In Visual Studio (2010 at least, but I recall past versions too), you can right click on the folder, within Solution Explorer, and then choose "Include in Project".
Then on the properties tab for each file (or select them all at once), you choose "Compile" for the "Build Action" property.
This worked for me.