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 ...
随机推荐
- springboot 集成 swagger 自动生成API文档
Swagger是一个规范和完整的框架,用于生成.描述.调用和可视化RESTful风格的Web服务.简单来说,Swagger是一个功能强大的接口管理工具,并且提供了多种编程语言的前后端分离解决方案. S ...
- React 长列表修改时避免全体渲染
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script ...
- 独热编码 pandas get_dummies
映射技巧 将'income_raw'编码成数字值 income_mapping = {'<=50K': 0,'>50K': 1} income = income_raw.map(incom ...
- 2019.9.25使用BP和Hydra爆破相关的服务
使用BP和Hydra爆破相关的服务. Hydra:九头蛇,开源的功能强大的爆破工具,支持的服务有很多,使用hydra爆破c/s架构的服务.使用bp爆破web登录端口. dvwa:web应用程序漏洞演练 ...
- mysql语句修改zencart产品原价为特价的倍数
mysql语句修改zencart产品原价为特价的倍数,下面语句将原价设为特价的3倍: ; ;
- jquery判断cookie是否存在
首先请加载jquery库与jquery cookie插件 http://code.jquery.com/jquery-latest.js http://files.cnblogs.com/afish/ ...
- 2017 ICPC 乌鲁木齐
H:题目看错 背锅 #include <bits/stdc++.h> #include <vector> #define PI acos(-1.0) #define mem(a ...
- Open Project' has encountered a problem
用Eclipse作android开发时,打开IDE,经常有的工程目录点击后会出现下面的问题提示: 这种情况往往是工程文件夹中的.project文件丢失了,所以从别的工程复制过来,就可以用啦.
- python之ORM
pymysql python操作数据库的基本步骤: 导入相应的python模块: 使用connect函数连接数据库,并返回一个connection对象: 通过connection对象的cursor方法 ...
- CSS 多行省略失效 (-webkit-box-orient 失效) Second Autoprefixer control comment was ignored. Autoprefixer applies control comment to whole block, not to next rules.
webpck不能编译这个属性-webkit-box-orient: vertical https://github.com/fanyifanbumaimeng/Articles/issues/48 / ...