App_Code folder in ASP.NET project in VIsual Studio 2010
-
29-09-2019 - |
Pergunta
at vs2008 i could set App_Code folder, but at vs2010 i can not do it, that's why i put my dataset's and class' to App_Data folder. Either I do not know even App_Data folder is secure? Any suggestions?
Thanks
Solução
Remember, that Web Site Project
can contain App_Code
folder and Web Application Project
can't! Because all project is for code.
Outras dicas
If you want to add the App_Code folder, you have to manually add the folder. Add->Add New folder--> you have to give it the folder name "App_Code" when you do it, and vs2010 automatically will change its folder type.
good luck
If you want to use standalone class files (in "App_Code" dir) in VS 2010 project, be sure set the File Properties > Build Action for each *.cs or *.vb file to "Compile" in the Properties > Advanced dialog.
Also, use the same namespace as your project and these standalone classes will be readily available to the rest of your project.
Took me a bit to realize the default setting in my VS was "Content" instead of "Compile."
Have you tried right-clicking on the project in the Solution Explorer, selected 'Add...' and looked under ASP.NET folders?
From memory, even previous versions of VS don't automatically put the App_Code folder in your project by default.
If you just create a folder called App_Code it will recognise it as the App_Code you want, it is strange that in the add .net folder it doesnt appear.
This the route I took for it, and it all works fine.
Workaround:
If we are using App_Code in a web application project, we need to rename into any other folder name.
I hope this will help you - the .cs files should not be placed in a folder. Just put them in the project, alone, and not in a folder. Then your classes will be visible. This is a difference in VS 2010.