【发布时间】:2014-04-17 20:30:48
【问题描述】:
我在 VS2005 中有一个现有项目。当我添加一个新的 asxp 页面时,该项目正在添加它,如下所示
<Compile Include="ASPX\myNewPage.aspx.vb">
<DependentUpon>myNewPage.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
我需要按照下面列出的方式添加它。
<None Include="ASPX\existingPage.aspx.vb">
<SubType>ASPXCodeBehind</SubType>
<DependentUpon>existingPage.aspx</DependentUpon>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
我们怎样才能像上面那样添加它?当我将文件复制到生产文件夹时,它们会导致什么差异?
参考
1 Does code in aspx page get compiled in a web application?
2How to work with code-behind class files in an ASP.NET application by using Visual Basic .NET
3Understanding ASP.NET Dynamic Compilation
编辑
以下是我添加动态编译页面的方法。
ASPX
<%@ Page Language="vb" AutoEventWireup="false" Src="WebForm1.aspx.vb" CodeBehind="WebForm1.aspx.vb"
Inherits="WebForm1" %>
代码隐藏
Public Class WebForm1
Inherits System.Web.UI.Page
遵循的步骤:
- 发布它
- 在 IIS 下运行它,指向已发布的位置。
- 从已发布的文件夹中删除 WebForm1.aspx
- 手动将 WebForm1.aspx 和 WebForm1.aspx.vb 复制到发布位置。
【问题讨论】:
-
这是特定于网站项目的吗?如果是这样,请尝试弄乱属性页上的 MSbuild 选项卡并检查“使用的固定命名和单页程序集”检查 nox。 IIRC 这在 as*x 页面中为您提供了稍微不同的指令。
标签: asp.net