Simply changing the literal HTML of an ASPX or ASCX file doesn't require re-compiling if the full file is part of the site.
If you need to change some compiled code you can use what I call the "patch method":
- Take the original codebehind file and change the class name (for example change "mypage" to "mypage_patch"). This step is important because the runtime would get a class name ambiguity because the same class would also exist in the precompiled assembly.
- Change the @ Page directive to use the "Src" attribute instead of the "CodeFile" attribute. The value can remain the same.
- Change the @ Page directive "Inherits" attribute to the new class name from the first step. This changes the page to use the dynamically compiled class instead of the precompiled version in the assembly.
- Make the necessary changes to the codebehind files.
(Important note: When using VB
, you might need to remove the namespace prefix in the "Inherits" attribute value. A VB
project specifies a default namespace for the project and the individual .vb
files don't include the namespace blocks around the code.)
- Deploy the changed ASPX/ASCX files along with the codebehind files.