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 ...
随机推荐
- python字典保存至json文件
import os import json class SaveJson(object): def save_file(self, path, item): # 先将字典对象转化为可写入文本的字符串 ...
- JavaScript里面9种数组遍历!
大家好,我在这里总结分享了JavaScript中的闹腾的数组循环家族. 1.大家最常用的for循环,我就不解释了: for(let i = 0; i < 5 ; i++){ console.l ...
- C语言字符串函数总结
原文链接 函数名: stpcpy 功 能: 拷贝一个字符串到另一个 用 法: char *stpcpy(char *destin, char *source); 程序例: #include <s ...
- 多线程编程-- part5 锁的种类以及辨析
java中的锁,可以分为同步锁和JUC包中的锁. 同步锁 通过synchronized关键字进行同步,实现对竞争资源的互斥访问的锁,. 原理:对于每一个对象,有且只有一个同步锁,在同一时间点,所有的线 ...
- NativeScript —— 初级入门(跨平台的手机APP应用)《二》
NativeScript项目结构 根文件夹 package.json —— 这是适用于整个应用程序的NativeScript主项目配置文件. 它基本概述了项目的基本信息和所有平台要求. 当您添加和删除 ...
- JDK1.8中LinkedList的实现原理及源码分析
详见:https://blog.csdn.net/cb_lcl/article/details/81222394 一.概述 LinkedList底层是基于双向链表(双向链表的特点, ...
- Q2Day79
requests Python标准库中提供了:urllib.urllib2.httplib等模块以供Http请求,但是,它的 API 太渣了.它是为另一个时代.另一个互联网所创建的.它需要巨量的工作, ...
- Java构造二叉树、树形结构先序遍历、中序遍历、后序遍历
package com.example.demo; public class BTree { public int data; public BTree left; public BTree rigt ...
- kubeDNS workflow(service registration and discovery)
Service discovery In k8s, we usually will more than make an application instance, and also the corre ...
- springmvc视图文件的保护
可以将视图文件,包含视图文件的目录放在WEB-INF下,WEB-INF是受保护的,放在该目录下,就只能在代码中访问到了view文件了,用户无法通过浏览器直接输入地址访问.