So are you saying that your code only doesn't work when you upload the published version of your application?
Are you pre-compiling the application or getting the server to do it?
Can you hit a .html page directly and a .aspx page directly?
Sounds like you are deploying to IIS 6, here are my IIS6 deployment notes for one of my apps which is 3.5 with url routing:
Add read / write
Add Default Application to Application name
Under configuration add a wild card mapping: add aspnet_isapi.dll, untick verify that file exists
Change ASP.NET version to 2.0
Under directory security add IUSR Anonymous and password.
make sure the directory has ASPNet user and IUSR accounts added in security folder tab.. v important
Hope this helps!