views:

28

answers:

1

I have a web application project that I wish to keep as a web application project, however is it possible to have part of it compiled on demand like a web site project? I would like one folder where I can add aspx pages to the website after its been published.

+1  A: 

Yes. The two can coexist quite well. Just drop your web site pages in and they will dynamically compile. Nothing about web application projects disables this feature or anything. You can also put code in the app_code folder and it will dynamically compile as well.

Managing this in visual studio can present some difficulties. The best bet, if your web site pages aren't dependent on code from the web application project, is to keep these projects completely separate in visual studio. When you deploy to a real web server, just deploy them both to the same place. Do be careful about files both have in common (like web.config) though.

BTW, there is a very long discussion on this topic in the comments section of an article I posted up a while back. I think you might find it useful as the discussion went into detail about mixed projects at one point.

Stephen M. Redd
Thanks, great info! I created an aspx page with its single code behind (but leaving the CodeBehind attribute out of the aspx file). I included it in Visual studio but set the .cs file's build action to 'Content' not 'Compile', and it does seem to work. The web application can be published, and then subsequent changes can be made to that pages code-behind which are used next time that page is requested. I am not sure where the compiled code for that page ends up though? I couldn't see them in C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files.
Sprintstar
Ya... check your "c:\Users\[myuserid]\AppData\Local\Temp\Temporary ASP.NET Files" location. They're probably getting dropped there if you are running this off VS with the dev web server.
Stephen M. Redd