In an ASP.NET website with a codebehind at what point are the .cs files compiled?
In an ASP.NET website with a codebehind at what point are the .cs files compiled?
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
.aspxfile hasCodeBehind="your.aspx.cs" - The properties of the
.csand.designer.csfiles in solution explorer have abuild-actionofcompile.
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
.aspxfile hasCodeFile="your.aspx.cs" - The properties of the
.csfile in solution explorer have abuild-actionofcontent - The properties of the
.designer.csfile in solution explorer have abuild-actionofnone.
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
.cswas compiled into the.dllin 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.dlland in the on-the-fly compiled code, which will lead to runtime errors.
In an ASP.NET website with a codebehind at what point are the .cs files compiled?的更多相关文章
- ASP.NET 调试出现<%@ Application Codebehind="Global.asax.cs" Inherits="XXX.XXX.Global" Language="C#" %>
ASP.NET 调试出现<%@ Application Codebehind="Global.asax.cs" Inherits="XXX.XXX.Global&q ...
- asp微信支付代码证书文件post_url.aspx和post_url.aspx.cs源码下载
很多朋友在网上找的asp支付代码中都没有这两个证书文件,只能是用别人的,但是如果别人把他的网站这个文件删了,你的支付也就不能用了,今天我就把大家需要的这两个asp微信支付代码证书文件post_url. ...
- Fiddler捕捉ASP.NET WebSite调用WebService、WCF服务
Fiddler默认会注册一个代理,有时会发现WebSite调用的WebService或者WCF服务无法被捕捉到.其实是由于运行的站点关联的应用程序池使用的账号和我们当前登陆操作系统的用户不同,自然它们 ...
- asp.net website 单独编译某个页面,连带编译app_code
选中某一个页面,然后右键build page
- ASP.NET: Setup a MVC5 website with MySQL, Entity Framework 6 Code-First and VS2013
The new features available in EF6 allow any developer to build a simple DB-powered website with very ...
- WebSite和WebApplication的区别
1. WebApplication(Web应用程序)和WebSite(网站)的区别:WebSite是为了兼容从ASP转过来的开发人员的习惯而存在的,用起来简单,例如:不需要创建命名控件.C#代码修改以 ...
- WebApplication与WebSite区别
1. WebApplication(Web应用程序)和WebSite(网站)的区别:WebSite是为了兼容从ASP转过来的开发人员的习惯而存在的,用起来简单,例如:不需要创建命名控件.C#代码修改以 ...
- 逐步改用 IronPython 开发你的 ASP.NET 应用程序
IronPython for ASP.NET 的 CTP 已经发布有一段时间了,我们在看了官方提供的范例之后,相信对一个 ASP.NET 应用程序中完全使用 IronPython 开发还是有一些担心的 ...
- POCO Controller 你这么厉害,ASP.NET vNext 知道吗?
写在前面 阅读目录: POCO 是什么? 为什么会有 POJO? POJO 的意义 POJO 与 PO.VO 的区别 POJO 的扩展 POCO VS DTO Controller 是什么? 关于 P ...
随机推荐
- leetcode 1051. Height Checker
Students are asked to stand in non-decreasing order of heights for an annual photo. Return the minim ...
- 01 Linux常用基本命令(一)
1.远程连接服务器 Xshell为例: ssh 用户名@IP地址 (ssh root@192.168.119.139) 查看服务器的IP地址: ifconfig (ip addr) 2.命令 1.ls ...
- 多Y轴,下拉框渲染,相同类型不同数据
放上json文件: { "2017年3月": { "outKou": "5525.86", "inKou": " ...
- dedecms 后台栏目全部展开 包括三级栏目
include/typeunit.class.admin.php 搜索以下代码并删除 style='display:none'
- cmake编译c++程序
当在Linux系统下编写程序时候,如果没有类似于visual studio.vs code等IDE(集成开发环境)时,如何编译.运行程序呢?一种方法是编写makefile文件,用makefile文件管 ...
- PAT Basic 1019 数字黑洞 (20 分)
给定任一个各位数字不完全相同的 4 位正整数,如果我们先把 4 个数字按非递增排序,再按非递减排序,然后用第 1 个数字减第 2 个数字,将得到一个新的数字.一直重复这样做,我们很快会停在有“数字黑洞 ...
- Java定时任务的几种方法(Thread 和 Timer,线程池)
/** * 普通thread * 这是最常见的,创建一个thread,然后让它在while循环里一直运行着, * 通过sleep方法来达到定时任务的效果.这样可以快速简单的实现,代码如下: * */ ...
- 我所亲身经历的CMMI3 [问题点数:20分,结帖人outer2000]--转载
很荣幸,作为某公司软件部门的软件项目经理,亲身经历了CMMI3,以下就把整个改进过程,用自己的亲身体会,详述如下,文中一些观点与看法难免带有个人感情,还请各位酌情参考. 公司情况简单介绍下,因为是为某 ...
- k8s资源需求及资源限制
在k8s上,可由容器或pod请求或消费的计算资源时指cpu和内存,这也是目前仅有的受支持的两种类型.相比较来说,cpu属于可压缩资源,即资源额度可按需收缩,而内存则是不可压缩型资源,对其执行收缩操作可 ...
- c# 判断某个类是否实现某个接口
typeof(IFoo).IsAssignableFrom(bar.GetType()); typeof(IFoo).IsAssignableFrom(typeof(BarClass));