Martin de Ruiter
Martin de Ruiter

Reputation: 525

Using codefile in web application project

Just read about the possibility to use codefile=somefile.aspx.cs instead of codebehind=somefile.aspx.cs in web application projects (described here). Obviously this causes the file the compile only when loading the page, it's not precompiled anymore (right?).

Are there any negative or unexpected side-effects by using codefile instead of codebehind in a web application project?

Upvotes: 4

Views: 1106

Answers (1)

Mxyzptlk
Mxyzptlk

Reputation: 536

I think you could run into problems for supportability if your site isn't all one or the other. (CodeFile or CodeBehind)

i.e. If you're trying to figure out a problem on your production site that your error handling tells you is within a certain file or namespace, you'll have to stop to examine every file and control that you are supporting before troubleshooting to see if the page is running as part of the compiled assembly or running from the codebehind on the site.

You could also run into conflicting or missing namespaces if you try to have a mixed environment.

Pros as I see it for CodeFile:

  • Your production source code can sit on your production website. If the code is all compiled in a DLL in your bin directory, there is no absolute guarantee that the code you have on your development environment or source control is what's out there. (Sure it SHOULD be, but if everything was always as it should be, many of us wouldn't have jobs fixing other people's code!)
  • For updates, you only have to push out single files, not an entire assembly.
  • You would be able to have developments in progress on other pages that you don't need to back out before recompiling and publishing to production.

Cons:

  • Since you're not pushing out a compiled assembly, you may have errors within individual files, that won't necessarily be caught unless someone visits each specific page or if you are sure to compile before deploying.
  • You may have conflicting namespaces in codefiles that may never be caught and could cause confusion or errors.
  • Performance issues for dynamic compilation

Upvotes: 3

Related Questions