ASP.net2.0中的特殊文件App_global.asax.compiled

在ASP.NET2.0中有好多不知道做什么作用的文件及文件夹。
1. App_global.asax.compiled
2.App_Code.compiled
3.PrecompiledApp.config

下面将介绍我采用Microsoft Web Deployment Projects在Visual Studio 2005中生成唯一程序集的方法。

先下载Microsoft Web Deployment Projects,地址是:
http://msdn2.microsoft.com/en-us/asp.net/aa336619.aspx

声明一下,我用的VS2005是Team suit版本的。

安装后在“生成”和WEB项目的上下文菜单看到“Add Web Deployment Project…”,好了,现在在解决方案中点你的网站项目名称,右键,添加一个Web Deployment Project项目,起一个名称,这个名称就是将来编译后生成的程序集名称,默认的名称“当前项目名称_deploy”(我的项目是Web_deploy),这样操作后项目解决方案中会多一个项目Web_deploy,然后我们对Web_deploy进行操作就可以达到我们的目的了。

右键打开Web_deploy项目的属性页面,察看“配置属性”,先看"Compilation"选项:

Compilation中的Output Folder设置项目输出路径,这个可以默认。
我们把Generate debug information和Allow this precompiled site to be updatable两项的对勾打上。

Output Assemblies中的四大选项:
1. Merge all outputs to a single assembly-所有输出都编译成一个程序集(参数:程序集名称) 1.1   Treat as library component (remove the App_Code.compiled file)-App_Code视为类库(删除App_Code.compiled文件)

2. Merge each individual folder output to its own assembly-WEB项目中单独的目录会编译到一个程序集中(参数:程序集前缀)

3. Merge all pages and control outputs to a single assembly-所有页面控件编译到一个程序集中(参数:程序集名称)

4.  Create a separate assembly for each page and control output-为每一个页面和控件创建程序集Signing使用key文件建立强命名空间的程序集这里我们只需要设置“1. Merge all outputs to a single assembly-所有输出都编译成一个程序集(参数:程序集名称)”(我设置的是Web_deploy)和“1.1  Treat as library component (remove the App_Code.compiled file)-App_Code视为类库(删除App_Code.compiled文件)”(这个对勾要打上)。

这样,我们再把程序的页面继承关系改一下就可以发布网站了!举个例子:

网站中每个ASPX文件的PAGE我们这样改:
Index.aspx
<%@ page Language="C#" MasterpageFile="~/MasterPage.master" AutoEventWireup="true"

CodeFile="Index.aspx.cs" Inherits="wjj.Web.Index" Title="首页" %>
注意其中的Inherits="wjj.Web.Index",wjj.Web是我网站的我自己定义的命名空间。

Index.aspx.cs也要加上命名空间

namespace wjj.Web
{
    public partial class Index : System.Web.UI.Page
    {
               protected void Page_Load(object sender, EventArgs e)
        {

        }
     }
  }

好了,点项目Web_deploy右键---重新生成就可以了,终于把问题解决了!

Index.aspx生成后的PAGE如下:
<%@ page language="C#" masterpagefile="~/MasterPageDefault.master" autoeventwireup="true"

inherits="wjj.Web.Index, Web_deploy" title="首页" %>

原文地址:https://www.cnblogs.com/rodney/p/886852.html