Am I a web site or a web app project: CodeFile vs. CodeBehind

I accidentally opened up a web application project as a website. That’s not too hard to do. Just say you want to open a web site and point to the folder. It had been a while and I forgot that it was a WAP.

So I’m working on a web page and double click on a control and find myself in the markup with a new script tag and the .net code for the click event of the control. That wasn’t good considering I already had some nice event handlers for that control in my code behind.

I spent a lot of time going back and forth trying to figure out why I couldn’t get to my code behind.

I even remembered having this problem in the early days of Web App Project and the solution was to “convert to a Web Application Project” from the context menu in the solution explorer. But this option wasn’t available.

I created a new web site and looked at the page directive and noticed that in the new website the parameter pointing to the code behind file was called CodeFile, but in my old site it was CodeBehind. Wierd.

So with that clue I googled those two words, came across Steve Smith’s blog post about the opposite problem and realized my mistake!

Duh. 🙂

  Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!  

One thought on “Am I a web site or a web app project: CodeFile vs. CodeBehind

  1. thanks!I have the same issue constantly and still haven’t nailed down the exact differences.I think it’s more annoying than anything.IMOHO it shouldn’t be so confusing…I always preferred the WAP approach where all code is compiled into a single assembly where you could simply migrate the new assembly.Seemed much more simple that way.Guess I’m crazy…

Leave a Reply to Wayne Cancel reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.