Website compilation process[AppCode DLLs] - c#

We are working on a website project which contains around 1130 pages. After compilation, all the .aspx.cs files are converted into AppCode DLLs that has random names.
Whenever there are any changes in single .aspx.cs file[like a hotfix], we have to recompile and deploy the entire project on the application host.
We want to update only those files that have been changed and not the entire package.
One of a solution we are aware is that, converting Website to Web application; but we cannot implement that change at this stage of the project.
Is there any other way to find an efficient solution for this?

Yup. Talking in Visual Studio 2010:
While publishing the website, Select the option: 'Use Fixed naming and single page assemblies', Also select 'Allow this precompiled site to be updateable'.
After website is published. Go to the published folder. Open any aspx page (not the dll or .cs).. Note the dll name in page attribute under inherits attribute. Than using ftp or any other way to upload, copy or upload tht dll under bin to your website.
Also, you can create a doc or txt file to list all Dll names with respective paths to your file to easily know which dll to upload next time if there is any change.
Hope it helps.

Related

asp.net c# .net framework 2.0 and 3.5

We have a asp.net application built in .net framework 2.0.
I need to edit a web report and add few columns to the report.
I updated the aspx.cs file and uploaded it to the server but there is no change in the report. If I change aspx file it works but aspx.cs file changes are not reflecting on the server. And I dont have local setup of the application to check.
Is it necessary to compile the file, but same thing I have done with framework 4.5 without compiling and it worked. How can I update the report without compiling the file.
In server it executes only compiled code, if you upload .cs files, it will affect nothing, so you need to upload compiled code(.dll) to see the changes.
you need to publish the new .dll file found in the bin directory to the remote locations bin folder.
If youre publishing through VS which I suspect your not, this would do this automatically on publish.
If youre doing what I think your doing and copying and pasting you need to copy the bin directory up too.
There are a number of files \ folders that you need but the aspx.cs files are not any of them.
In ASP.NET when you place the aspx and aspx.cs file the files get complied automatically before the execution by ASP.NET engine. Please check the updated code does it contain any reference from 4.5 library.Additionally you can try to referesh the IIS cache sometimes ASP.Net engine unable to refresh/replce the existing files in the cache folder.

Cannot deploy website using "Precompile during publishing" option

I am trying to publish my web app.
Here is a picture of my setting for my publishing profile:
As you can see, I have the "Precompile during publishing" option checked.
Here is the Configuration settings for "Precompile during publish".
When this is checked, and I try and publish my web app, I get an error on one of my pages. When I hover over the tab to see the file location, the location is at: C:\Users\akemp.WT\AppData\Local\Temp\WebSitePublish... This is not the location of my source code, and if I make the changes on my local page, the site in the above given path does not get updated.
When I unchecked the "Precompile during publishing" option, my website published without any hassle.
What is going on here?
Pre-compilation means all your source code (including aspx.cs files for web site projects, class files under app_code folder, resx files, the global.asax file, and even the aspx files - unless "Allow precompiled site to be updatable" is selected) are combined and compiled into assemblies.
global.asax will have it's own assembly, app_code will have it's own, resx files wll be compiled in assemblies per folder, while the rest of the source code (aspx, aspx.cs) will be compiled into a single (and huge, depending on number of pages) assembly, and all will be in the bin folder of the web application as dll files.
If you do not pre-compile, these resources (aspx files for instance) will be compiled with the first request targeting that page.
This will enable you to make aspx and aspx.cs deployments without recycling the application.
And because a web site canot be both pre-compiled and compiled-on-demand, VS cannot run your published web site where your source code is located. But if you don't pre-compile, your source code can directly be served (since the first request will compile the resources and the compiled assemblies will go under C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files (or another explicitly set temp path for shadow assemblies)
When I tried publishing with the "Precompile during publishing" option checked, I got an error on one of my code behind files.
When I made changes to my code behind file in visual studio, saved and rebuild my solution, and then tried to publish, the issue would still exist. When I double clicked on the error in the Error list, it opened my page's code behind file, except for the fact that it was the file located at "C:\Users\akemp.WT\AppData\Local\Temp\WebSitePublish...\RandomPage.aspx.cs", and not located at my source folder.
After I individually published that page on it's own (Right click on RandomPage.aspx.cs, and select Publish RandomPage.aspx.cs), I was able to publish my web app with the "Precompile during publishing" option checked.

Can I compile a single aspx.cs file into a DLL?

I'm attempting to make a single small update to a website written in C#/ASP.NET.
All I'm trying to do is change the email address a form submits to, which is why I'm not seeking out a proper C#/ASP.NET developer.
I've done a little research, and it seems that the site itself is using dll files in the /bin folder to run the forms and things. The form is contact.aspx.f3293f9sd.dll, so I've edited the corresponding contact.aspx.cs file.
What do I do now?
Can I build this single CS file into a single DLL and upload it? I've scoured the menus and see no such option, and Google results seems to imply that you need to add entire projects and build entire projects at once.
Is that correct? What's the process here?
What you need to do is open the solution file. Solution files are files composed of projects. The contact.aspx.cs file is part of one of those projects. You need to make your change in the file, then recompile your solution. Then you can upload the DLL file it outputs to your production. Make sure you compile in Release mode.

In an ASP.NET website with a codebehind at what point are the .cs files compiled?

In Brief:
In an ASP.net website with a code-behind, at what point are the *.cs files compiled?
Context:
A colleague who has since left, deployed a website with a .cs code-behind to a shared server. I have made a small change to a .cs file, which I should expect to reflect on one of the pages but it has not yet appeared. I have restarted the application pool, however I am loathe to reset IIS on the server as there are couple of other teams' apps which might be be in use on the same server.
This applies to Web Application projects as opposed to Web Site projects, which are CodeFile by default, and don't allow changing the build action...
In ASP.NET Web Applications you have two methods of deploying your pages; CodeFile and CodeBehind. By default pages will always use CodeBehind but you can change this.
CodeBehind
CodeBehind compiles your .cs file into the .dll file in your bin folder at compile/build time, and then you deploy that to your web server. There is no need to deploy the .cs file to your web server. If you do, it will just sit there being unused.
To configure a page with CodeBehind, ensure that:
The page directive in your .aspx file has CodeBehind="your.aspx.cs"
The properties of the .cs and .designer.cs files in solution explorer have a build-action of compile.
CodeFile
This causes ASP.NET to compile the .cs file on-the-fly on the server. This means that your .cs file needs to be deployed to the web server. It also means that your .cs file will not be compiled at compile/build time and therefore not built into your .dll in the bin folder.
Key advantage
With CodeFile, You can make changes to the .cs file and deploy just that file to see the changes on your production web server. No need to re-deploy. No need to recycle the app pool. This can be very useful in a lot of situations.
To configure a page with CodeFile, ensure that all of the following are met:
The page directive in your .aspx file has CodeFile="your.aspx.cs"
The properties of the .cs file in solution explorer have a build-action of content
The properties of the .designer.cs file in solution explorer have a build-action of none.
Notes
Intellisense doesn't like working when pages are set up with
CodeFile (you can change to CodeBehind whilst coding and then change back for deployment, though).
If you change from CodeBehind to CodeFile, then always do a
rebuild and re-deploy (and vice versa). This is because when the page was CodeBehind,
the .cs was compiled into the .dll in the bin folder, and will
remain there when you change to CodeFile. The CodeFile will be
compiled on-the-fly and you will get the same code/classes defined in
the .dll and in the on-the-fly compiled code, which will lead to
runtime errors.
For the setup I use, the .cs files are compiled when building the project. This means it is the .dlls in the bin that need to change, not the .cs files directly.
The .aspx files can change at any time, but I think you need to rebuild the project in order for the code behind to take effect.
I have replaced singular .dlls before without any problem (though it's not good practice).
Apparently what you have done should work.
Check if Cacheing has been implemented.
Otherwise publish the code and deploy the dll, instead of .cs file. I would recommend to test in staging server before you go live.

Convert ASP.NET Web Application to ASP.NET WebSite

SCENARIO: A developer at work has created an three-tier ASP.NET Web Application which plugs into the company website, however the rest of the site was done as an ASP.NET Website. For clearity, his portion used Web Application (compiled into single .dll) and the rest of the site is WebSite (seperate .dlls). I do not wish to recompile the website every time a change is made to a page.
QUESTION: Is it possible to convert a Web Application
to a Website without rewriting the entire application?
TRIED:
Created WebSite and copied & pasted files over
Changed'CodeBehind' to 'CodeFile'
Deleted .designer.cs from pages and controls
Checked References
Ok - assuming you have a backup, this is how I would tackle it:
Delete the csproj file
From within Windows Explorer, delete any designer.cs files
Still in Explorer, create an App_Code folder at the root of the site
Find any *.cs files that aren't code behinds (eg., .ascx.cs or .aspx.cs) and move them into the App_Code folder
Open in Visual Studio as Web Site project
Verify .NET FX version
Change CodeBehind= to CodeFile= in any .aspx or .ascx files
Readd any 3rd party references
There's some potential complications around Global.asax, ASHX handlers (need to be inline) and referencing pages and controls. You'll have to deal with those manually, I'm afraid - but if it's a smallish effort, it should be easily doable.

Categories