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
.aspx
file hasCodeBehind="your.aspx.cs"
- The properties of the
.cs
and.designer.cs
files in solution explorer have abuild-action
ofcompile
.
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 hasCodeFile="your.aspx.cs"
- The properties of the
.cs
file in solution explorer have abuild-action
ofcontent
- The properties of the
.designer.cs
file in solution explorer have abuild-action
ofnone
.
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.
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 ...
随机推荐
- 原生javascript的意义
原生JS是指遵循ECMAscript标准的javascript,不同于微软的jscript也不依赖于任何框架,依托于浏览器标准引擎的脚本语言. jquery是在原生态的js上集成的框架资源,使用jqu ...
- adb进阶知识,如何过滤只查看某一个app的日志
前面大概学习了adb基础,但是adb的存在,在测试人员中究竟有什么必要,以及看log时,那么多的log,让我们看个屁啊,所以这一次,我决定一定要把adb这件事情搞清楚. 1.先来看最感兴趣的adb ...
- 1.什么是bat文件
bat文件是dos下的批处理文件.批处理文件是无格式的文本文件,它包含一条或多条命令.它的文件扩展名为 .bat 或 .cmd. 在命令提示下输入批处理文件的名称,或者双击该批处理文件,系统就会调用c ...
- win7-32位安装mysql-5.7.27
下载 https://dev.mysql.com/downloads/mysql/5.7.html#downloads 参考链接 https://blog.csdn.net/qq_41307443/a ...
- docker快速入门02——在docker下开启mysql5.6 binlog日志
1.检查容器状态 [root@localhost ~]# docker ps 执行这个命令可以看到所有正在运行当中的容器,如果加上-a参数,就可以看到所有的容器包括停止的. 我们可以看到容器正在运行当 ...
- Linux部署java和tomcat的运行环境
Linux部署java和tomcat的运行环境 1.上传下载的jdk的rpm包和tomcat的tar包,我是放到/opt目录了,文件直接去官网下载即可. 2.如果之前安装过其他版本的jdk,最好先现在 ...
- 服务器挂载 ntfs32 硬盘
1,fdisk -l 查看硬盘名称 2,mount -t ntfs-3g /硬盘名/ /目标目录/ 3,umount /硬盘名/ 4,如果卸载不了 就fuser -km /目标目录/
- Java语言基础(3)
1 算术运算符:+,-,*(乘法),/(除法),%(求余数) 1)只有相同类型的数据才可以进行算术运算,经常使用到自动类型转换和强制类型转换,把参与运算的数据转换为同一个类型,然后再进行算术运算. 案 ...
- javascript模板字符串(标签函数)
前面介绍了javascript的模板字符串的基本知识,今天深入学习一下标签函数 模板字符串概述 这里先简单说一下模板字符串的概念 1.模板字符串,从名字上可以得出其实返回的是字符串,普通使用其实就想引 ...
- @InitBinder的作用
由@InitBinder表示的方法,可以对WebDataBinder对象进行初始化.WebDataBinder是DataBinder的子类,用于完成由表单到JavaBean属性的绑定. @InitBi ...