asp.net c# .net framework 2.0 and 3.5 - c#

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.

Related

Published aspx.cs file to azure server, But latest code dosent work

I just published a aspx.cs server code change to my web application from visual studio 2015,with the same azure profile.But the code wont work, it still takes the old code.
When I look at the comparison of aspx.cs files in server and local, it is the same. The new one.
However the changes done to the html part gets reflected, but changes to aspx.cs will not?
Why is it so ? Kindly help
According to your description, I assume that you are using a Web Site project and your source code is deployed to Azure directly without be compiled. In this situation, the first request to your website could require the site to be compiled, which could result in a delay.
When I look at the comparison of aspx.cs files in server and local, it is the same. The new one.
However the changes done to the html part gets reflected, but changes to aspx.cs will not?
Since you have restarted your web app, please try to precompile your website during publishing as follows:
Note: Please try to tick the "Precompile during publishing" box, which could leverage all code-behind class files and standalone class files in your project compiled into a single assembly, then put in the web application project's Bin folder. Also, you could check the "Remove additional files at destination" box to empty the website content before publishing your website. For more details, you could follow this tutorial.

Removing Code Behind from a deployment

I have a site that I'm about to publish and I want to know how to set it so it would not deploy the code behind?
Essentially i'm trying to find the difference between an aspx file that calls the code behind .cs file and another that calls a dll that's in the BIN directory?
The below explanation from the Microsoft ASP.NET documentation discusses the difference between explicit and automatic compilation.
In order for the ASP.NET engine to service a request for this page,
the page's code portion (the WebPage.aspx.cs file) must first be
compiled. This compilation can happen explicitly or automatically.
With explicit compilation you need to copy up the assemblies in the
Bin folder, but you do not need to copy up the ASP.NET pages' code
portions (the WebPage.aspx.cs files).
With automatic compilation you need to copy up the code portion files
so that the code is present and can be compiled automatically when the
page is visited.
When you publish a web project (from Visual Studio), the source code from code behind (.aspx.cs files) will be converted to a binary dll file named as [YourWebProject].dll and will be copied under the "bin" folder.

Website compilation process[AppCode DLLs]

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.

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.

Hiding codebehind files on web server( hiding programming logic)

We are publishing our website using VS10
1) While publishing the website Localy, only aspx files are grouped together in the published folder and that web is working fine in the local IIS server.
2)though .cs files are not in the published folder all the events are working well in Local iis server
3)what I am doing..... I am coping that published web folder and uploaded it to the web server.
4)but now it showing an error for every event I calling????
5) how can I tackle this problem??
6) For security reason I don't want to upload my code behind files to web server?? I want to hide my programing logic how can I do this ????
7) when I am uploading my web with both the .cs and aspx files it working well but I don't want to do this??
You need to publish your website it will generate dll put that instead of putting .cs files. This codeproject article explains how to do it.
You do not need to copy all of the files. You only need to upload the .ASPX file and the Bin folder which will contain the compiled logic in a DLL named YourProject.DLL and also any other references that are required. The .CS files containing your actual code are not required on the server as they have been compiled into the DLL.
With JavaScript you cannot hide this from the user because it is needed on the client-side. However, you should save all of your JavaScript into a .JS file and include on the page. At least it makes it less obvious to someone viewing the source of your page.
Publishing your web site will do the job.
Please read How to: Publish Web Sites (Visual Studio)
and
ASP.NET Web Site Project Deployment Overview

Categories