使用ASP.NET 1.1将代码隐藏程序集/ DLL移动到与/ BIN不同的文件夹中

Apparently there's a number of places online that say this can't be done. We needed to be able to add pages to an existing application that were basically "sub-applications," and they'd have their own /bin folder, but still be in the same VDIR and participate in the same IIS Application.

显然,在线上有很多地方说无法做到这一点。 我们需要能够将页面添加到基本上是“子应用程序”的现有应用程序中,并且它们将具有自己的/ bin文件夹,但仍位于同一VDIR中并参与同一IIS应用程序。

So instead of:

所以代替:

/webapp
 default.aspx
 foo1.aspx
     /bin
      app.dll
      foo1.dll

/ webapp default.aspx foo1.aspx /箱app.dll foo1.dll

We could have

我们可以有

/webapp
 default.aspx
     /bin/mysubapp
      foo1.aspx
          /bin
           foo1.dll

/ webapp default.aspx /箱/ mysubapp foo1.aspx /箱foo1.dll

If you try this directory layout as is, you'll get a "Parser Error" as ASP.NET freaks out due to its inability to find the code-behind for foo1.aspx.

如果按原样尝试此目录布局,则由于ASP.NET无法查找foo1.aspx的代码隐藏信息而会出现“解析器错误”。

However, if you add a private probingPath to your web.config:

但是,如果将私有probingPath添加到web.config中:

<configuration><runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="mysubapp/bin" />
    </assemblyBinding>
  </runtime>
<configuration>

<配置> <运行时> <assemblyBinding xmlns =“ urn:schemas-microsoft-com:asm.v1”> <probing privatePath =“ mysubapp / bin ” /> </ assemblyBinding> </运行时> <配置>

And, tell your ASPX page where it can find it's code-behind file BEFORE the System needs it for the Inherits= attribute in the @Page directive:

并且,在系统需要@Page指令中的Inherits =属性之前,告诉您的ASPX页面可以在哪里找到它的代码隐藏文件:

<%@ Assembly Name="Foo1" %>
<%@ Import Namespace="FooNamespace" %>
<%@ Page language="c#" Trace="true" Codebehind="Foo1.aspx.cs" AutoEventWireup="false" Inherits="FooNamespace.FooWebForm1" Debug="true"%>

<%@程序集名称=“ Foo1 ”%> <%@导入命名空间=“ FooNamespace ”%> <%@页面语言=“ c#” Trace =“ true” Codebehind =“ Foo1.aspx.cs” AutoEventWireup =“ false” Inherits =“ FooNamespace.FooWebForm1 ” Debug =“ true”%>

You'll be all set. Slick. Of course, this is all ASP.NET 1.1, and everything changes with 2.0 and the "/Code" directory, but it's still slick IMHO, and allows for a level of flexibility that I haven't seen before.  It also keeps your man/bin nice and tidy if you've got folks "plugging in" other pages to your web app.

一切准备就绪。 光滑当然,这都是ASP.NET 1.1,并且所有内容都会随2.0和“ / Code”目录而变化,但是它仍然很漂亮,恕我直言,并且具有我从未见过的灵活性。 如果您让其他人“将”其他页面“插入”到您的Web应用程序中,它还可以使您的man / bin保持整洁。

翻译自: https://www.hanselman.com/blog/moving-the-codebehind-assembliesdlls-to-a-different-folder-than-bin-with-aspnet-11

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值