Search This Blog

Monday, August 1, 2011

Releasing Single / Multiple Files To Pre Compiled ASP.net Web Site

We most the time run into the issue where we need to release a patch which requires a change in one or multiple code behind files and since your site is compiled, you are put into the state that you have to do a deployment instead of releasing those files. But, fortunately you can do that on a ASP.net website.

If your site is a ASP.net web application, then there is no shortcut since the application is compiled into a single class library and you have no option but to publish the site and this article will not help you. However, if you are using a web site, well here you go.

I created a default web site and published it. Remember to check the option which allows to update the site after compilation.

image

Now let me assume that I need to change the Default.aspx.cs file for some fix after publishing, and if I get into the published folder, I will not be able to see any code behind files. Below is how I see the aspx file.

image

As you can see, the “inherits” value is changed to get the class “_Default” from a assembly called "App_Web_yqoiawao" which was generated while publishing. You can find all these dlls inside the “bin” folder. If you have selected “Use fixed naming and single page assemblies” option you will see seperate assemblies for every page. Now lets not disturb them and concenterate on making a release on the code behind file “Default.aspx.cs” where we made the change.

All you have to do is copy the “Default.aspx.cs” file to the same location of “Default.aspx” and edit the “Default.aspx” and change the page tag to have as

CodeFile="Default.aspx.cs" Inherits="_Default"

Well thats it, you have made a release for a single file. Remeber now the Default page is no more precompiled and it will compile for every request made. Don't use this option unless you cannot really afford to make a release and you need a quick fix.

No comments: