khawarPK
khawarPK

Reputation: 2217

asp.net publish and nonpublish code deploy

My publish site is deploy on different dedicated servers. Oftenly we recive page level chaneges from client, which need changes in both client and server side code, we first done change locally then i deploy that page with server side code on server without full publish build code because my client asked minor changes agaian and again, when client satisfied with the page changes then i put publish version on servers. i want to know what is mains difference in publish and non publish code deployment? when i put aspx with aspx.cs on server it works fine then why it is important to deploy a publish version.

Upvotes: 1

Views: 824

Answers (1)

danludwig
danludwig

Reputation: 47375

when i put aspx with aspx.cs on server it works fine then why it is important to deploy a publish version.

It's mostly a matter of efficiency. When you put the ASPX and ASPX.cs (codebehind) files on the server together side-by-side, that codebehind file will get compiled into its own assembly (.dll file) when someone first requests the page. You are actually pushing the source code to your server, not the compiled code. If you do this with each ASPX file, you could end up with dozens to hundreds of separate individual assemblies (one for each ASPX file), and one drawback is the delay while the compiler first converts the source code into a binary dll. Another is that your server has to manage a ton of assemblies instead of just one.

When you deploy a publish version, the compiler will merge all of your codebehind files into a single assembly. It will also alter your @Page directive in your ASPX files slightly. You end up with no source code deployed to the server, only a single binary DLL, which is more efficient.

So if you are only making ASPX changes (things like styles, plain HTML, etc), it is okay to push those out individually, as long as the @Page directive matches the codebehind that was pre-compiled and already deployed. However when you change both ASPX and codebehind, you should do a publish because it will result in a different merged codebehind assembly, which must be deployed to the bin folder on your server.

Sometimes what I will do is deploy ASPX and codebehind together to test something on a server, and once I'm sure it works, go back and do a publish deploy to bake the codebehind changes into the merged DLL. Then just push those to files (dll and ASPX), delete the codebehind source, and done.

Upvotes: 1

Related Questions