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
Related
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.
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.
Please could you explain this concept I can't seem to get my head around...
Within a C# ASP.Net web application written in Visual Studio, I have added an XML file which is being read by the code. To add the file, I physically copied it into the relevant folder within my web application, and then in Visual Studio added a reference to it within an "xml" folder, which is in my "_resources" folder.
The C# code is accessing the XML file in the following way:
using System.Web.Hosting;
string path = HostingEnvironment.MapPath(WebConfigurationManager.AppSettings["XMLFilePath"]);
The XMLFilePath value is set in the Web.config file as follows:
<add key="XMLFilePath" value="~/_resources/xml/anXMLFile.xml"/>
The file is successfully accessed when I'm testing locally. I then check it in, (into my source control system), then the application builds automatically on the web server. Then comes the problem... the file cannot be found and is not in the folder I would expect it to be in on the web server. If the automatic build is happening correctly, (which is quite a big if right now), am I right to assume that, as the file is present within the web application, it would then be present on the web server?
Right click the xml in Solution Explorer, go to Properties and make sure its Build Action is Content
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.
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.