Thursday, May 15, 2008

CodeFile and CodeBehind

When developing web sites (no project file), Visual Studio adds the CodeFile attribute to associate the aspx page with the corresponding cs or vb file. Web application projects use the CodeBehind attribute instead. It's just one of those things to watch out for when migrating your ASP.NET web site project to an ASP.NET web application project.

3 comments:

Ryan said...

AMAZING. why cant microsoft tell me this simply!!! HOLY SHIT THANK YOU

Nitin R.K. said...

Hi Ryan!

Thanks for your comment.

You don't have to manually change the CodeFile attribute to CodeBehind - you can right-click and select Convert to Web Application so it's done for you automatically.

The website model was confusing for amateur developers - the circular reference error was the most common of the lot... file A in folder A refers to file B in folder B while file C in folder B refers to file C in folder A. The web application model fixes that issue.

However, the ability to simply point IIS directly to the website folder during development let's me write ASP.NET applications even on mediocre hardware. When I need to debug, I simply attach the debugger. With a Web Application, I have to Publish or run from Visual Studio and that gives me enough time to go grab a cup of coffee :-P

-Nitin

GMac said...

I second what Ryan said...
I've searched everywhere for a good explanation of CodeFile vs. CodeBehind--and your page is the first to succeed. Congrats.