I've recently become the maintainer of an ASP.NET web project. In the course of deploying some changes, we noticed that at some point the way the project deploys has changed. The project is a web application project. Currently, when I "Publish" it to my local machine, I can open the various .aspx files and see some code--a little ASP, mostly JavaScript, but the majority of the code seems to be compiled into a .dll.
What we would like is to build and deploy this application so that there is no code in the .aspx files--this is how it used to work, before the previous dev stopped maintaining it. There should be no code in the .aspx files at all, just a reference to the compiled .dll files.
Does anyone know what I'm talking about and how to set it up?
EDIT If it helps, it looks like the older version of the app just had text in the .aspx files that said "This is a marker file generated by the precompilation tool, and should not be deleted!" That is what I'm going for.
ASP.NET - Deployment. There are two categories of ASP.NET deployment: Local deployment : In this case, the entire application is contained within a virtual directory and all the contents and assemblies are contained within it and available to the application.
Steps to Deploy ASP.NET Core to IIS Step 1: Publish to a File Folder. Step 2: Copy Files to Preferred IIS Location. Now you need to copy your publish output to where you want the files to... Step 3: Create Application in IIS. First, create a new IIS Application Pool. You will want to create one ...
In order to achieve no code in the .aspx files you need to write all the code in the code behind. You use the asp.net events in the life cycle to perform the generation of client code. For example, dynamically generated HTML and javascript could be generated in the Page_Load and written out as a Response.
There are several ways you can deploy to IIS using Visual Studio and Web Deploy: Use Visual Studio one-click publish. Publish from the command line. Create a deployment package and install it using IIS Manager. Create a deployment package and install it using the command line.
If you want to do this for your Website just Pre-compile your project for deployment only. You can check out the exact steps in this MSDN article
This will move all the codebehind files into the .dll and create .aspx.compiled files as pointers to the compiled versions in the .dll. Sounds like thats what was being done before.
The code shouldn't be visible from the client's browser.
Any code that in a code-behind will get compiled to a .dll
which the pages in the application would reference. The actual code-behind files shouldn't get published with the .aspx
files.
.NET code within the .aspx
files shouldn't be visible on the client-side because it has no use on the client-side. It should be executed on the server-side to render HTML output to the client. If the .NET code is visible on the client-side in this case, it means the server isn't executing it and the site is essentially broken.
JavaScript code, of course, needs to be visible on the client-side. There are ways to obfuscate it, but the browser needs to see it in order to execute it. So in this case that code should be developed with the full understanding that it is publicly visible and nothing proprietary or compromising should be included in it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With