C# – How come classes in subfolders in the App_Code folder are not being found correctly

app-codeasp.netcnamespaces

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?

Best Answer

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>