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
Remember, that Web Site Project can contain App_Code folder and Web Application Project can't! Because all project is for code.
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.
http://blogs.msdn.com/b/chiranth/archive/2014/02/19/visual-studio-2012-unexpected-behavior-crash-and-irrelevant-errors.aspx
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.
Related
I get some troubles with a DLL reference.
I have MySql.Data.dll in my bin folder. And I added the reference of this dll to my project.
I can well use classes from this dll (like MySqlConnection, MySqlClient, etc) in aspx.cs but i cannot use it in classes from files from App_Code folder !
For all files situated in App_Code folder (my model classes) , the using MySql.Data; doesn't work. While it works in aspx.cs files.
As you know, there are two types of projects that you can use to create a website in Visual Studio. The App_Code folder works for Web Site projects, but since you stated that you're using a Web Application project, this is causing you problems.
Here's some additional reading on this topic.
In short, I recommend just creating a different (non-built-in) folder to put your random code files in. Name it something like "code", "classes", etc.
I have a web site project with three referenced project. The question is really simple. For the refereneced project (say Project A and Project B referenced from Web Site Project). All I want to do is to reference it in the Web Project but I don't want it to copy to the 'Bin' folder of the web site project. I want it to copy to a folder that I define. Is there a way to do that? Many thanks.
I'm pretty sure you cannot change the ouput path if you build the referenced project. You can change the properties of the reference in the node references by right-clicking => properties, there is a property called copy local which will prevent the copy in the /bin folder. This means you will always reference whatever version of the dll is being pointed at in the Path property
Not so much a direct programming query - more just for info/knowledge...
When I click on Publish (VS2012 RC), and I look in the release folder, I can only see folders for bin, content, images, scripts and views.
There is no controllers folder.
Is this because VS packages up everything into the DLLs within the BIN folder?
Thanks, Mark
The DLLs inside your bin folder has the code for the controllers and other class files(Ex : Your Model classes). If you use any decompiling tool, you can see that.
DLL (dynamic-link library) files contain the executable code for the Web site, such as the class file that you created. Your application will works fine with those DLLs because all your code(your methods/ properties etc..) is available in that.
Your controllers (and any other .cs files) are compiled into a dll in the bin folder.
I've got a ASP.NET project without the .proj file. How do I recreate the project file, so I can work on it on my machine?
Is this possbile?
Are you sure it's not a Web Site Project, as opposed to a Web Application Project? Web Site projects do not have project files - you open a folder rather than a project file. See here for the differences between the two.
To check, each page of a Web Application project will have a .aspx, a .aspx.cs and a .aspx.designer.cs, whereas the Web Site project pages don't have the designer files.
You can create a new project and then you can use the "Add Existing Item" and add each of your files (you can select multiple files).
EDIT:
Or your can drag and drop the files into the "Solution Explorer"
First of all, you need to run VS2005 SP1 or later. In VS2005, they removed the project file. They reintroduced it again in SP1.
If you don't have a project file, your project is called a "Web Site". If you have a project file, it's a "Web Application". One difference between the two is also that in a web application, you compile all code-behind files to a single .dll. In a web site, each code behind file goes in its own dll (or are compiled dynamically at runtime)
I believe that if you right click the project in solution explorer, there is a "Convert To Web Application" menu item.
Note, you must rename the App_Code folder to something else, otherwise it will be compiled both at compile time, and at runtime.
Personally I much prefer web applications to web sites
I was trying to create a Dynamic Data Website using VS 2010 RC. An attempt to create an App_Code folder where I would put a LINQ to SQL class, failed. When I selected 'Add ASP.NET Folder' to add the folder, I had options to create only the following folders:
App_GlobalResources
App_LocalResources
App_Data
App_Browsers
Theme
What happened to the App_Code folder?
Why not create another project, a class library, and put it in there. That's by far the best way to keep those classes separate from the rest of your website.
To answer your specific question about the App_Code folder, it's available in WebSite projects as an Asp.Net folder you can choose from. But from a web application project, you can just create a new folder and name it App_Code and it will work just fine. This is as of Visual Studio 2010 RC.
you can't/shouldn'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. If you do add this manually, you may end up getting name clashes as the class will be precompiled to the dll and then asp.net will again try to recompile at runtime.
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.
I am working on my own web project for www.athenatennis.com.sg and am going thru a similar learning curve with that.
You can manually create the App_Code folder and add your class inside.
One thing you need to take note is... in the file properties, make sure the Build Action is set to Compile.
I also found this funny that it is missing. The thing is you "don't" need to create the App_Code folder you just add the classes to any new folder.
In VS 2005 any class outside the App_Code would give a compile error.
So I also want to know why they decided to remove this constraint? Was it because of people complained about it, or did the design concept changed and it was deemed necessary?
If you want app_code folder, you must create "ASP.NET web site". Once done, right click on website (Solution Explorer)-> Add ASP.NET folder->App_Code.
If you are looking at app_code folder inside "ASP.NET web application", you are wasting time.
in VS 2010, you need to create a solution, then right-click -> add new website, then when you add classes, linq2sql etc, vs will create the app_code folder for you
if you create a class, it will ask you if you want to add it on a App code folder.
It is very easy, just add the new class from 'Add New Item'. Visual Studio 2010 will automatically show the message that "Do You want to place the file in App_Code Folder". Just click OK.