Just as a point of interest, and in case it helps anyone.
I like using projects when working with VS Web Applications. Using a project gives you the advantage of setting up specific source control arrangements, and also excluding files from your site which you don't need cluttering up your project explorer.
However, if I need to work on a Web Site (not Application), project files aren't supported. But I found that it can be done, giving you the advantages of using a project file.
Simply start the site as a Web Application, but in all aspx or ascx pages you have to change the CodeBehind= parameter to CodeFile=. If there's a namespace (eg. "WebApplication1._Default") then remove it (ie. just "_Default").
Create a new folder in your project, called "App_Code", then restart VS. Whenever you create a new Class file in that folder, you need to right-click the file in the project explorer, select Properties, and change Build Action to "Compile". That's the trick,
as I guessed from reading MS's
responses to this post.
Also note that all pages will now have "designer" files associated with them, which isn't usually the case with normal Web Sites, but that's a good thing.
So now you have the advantages of a proper project, while working on Web Sites.
Member
2 Points
33 Posts
App_Code folder in Web Applications
Mar 05, 2010 12:54 AM|wibble|LINK
Just as a point of interest, and in case it helps anyone.
I like using projects when working with VS Web Applications. Using a project gives you the advantage of setting up specific source control arrangements, and also excluding files from your site which you don't need cluttering up your project explorer.
However, if I need to work on a Web Site (not Application), project files aren't supported. But I found that it can be done, giving you the advantages of using a project file.
Simply start the site as a Web Application, but in all aspx or ascx pages you have to change the CodeBehind= parameter to CodeFile=. If there's a namespace (eg. "WebApplication1._Default") then remove it (ie. just "_Default").
Create a new folder in your project, called "App_Code", then restart VS. Whenever you create a new Class file in that folder, you need to right-click the file in the project explorer, select Properties, and change Build Action to "Compile". That's the trick, as I guessed from reading MS's responses to this post.
Also note that all pages will now have "designer" files associated with them, which isn't usually the case with normal Web Sites, but that's a good thing.
So now you have the advantages of a proper project, while working on Web Sites.