See the question and my original answer on StackOverflow

What you could do is change the ASPX, so for example instead of this:

<%@ Page Language="C#" CodeBehind="MyPage.aspx.cs" Inherits="MyNamespace.MyPage" %>

You could change it like this:

<%@ Page Language="C#" Inherits="MyOtherNamespace.MyNewPage" %>

Write the new behavior in a new MyOtherNamespace.MyNewPage class (that should derive at least from System.Web.UI.Page) that you can put in any .DLL assembly that you deploy in the bin directory.

You can also derive this new class from the original page (just reference the original assembly) instead of just deriving from System.Web.UI.Page, if deriving is an option for you, depending on the changes you need to do.

Otherwise, you will have to reconstruct the original code using a tool such as .NET Reflector or ILSpy to build this new class, but at least, you don't have to touch the existing compiled assembly.