单独程序集中的 ASP.NET 母版页
我在一个程序集中有一些 ASP.NET 母版页。 我需要将这些母版页与位于其他程序集中引用第一个程序集的 WebForm 页面一起使用。 我似乎想不出办法做到这一点。
有什么好的方法可以让我做到这一点吗?
如果不存在漂亮的解决方案,我还想听听可能的黑客攻击?
I have some ASP.NET Master Pages located in one assembly. I need to use these Master Pages with my WebForm pages located in other assemblies that have a reference to the first assembly. I cannot seem to figure out a way to do this.
Is there a nice way that I can do this?
If no pretty solution exists I would also like to hear about possible hacks?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个问题没有很好的解决方案。
您可以做的就是将其放入单独的 Web 应用程序项目中并预编译它。 然后将预编译的 dll 并 ILMerge 将它们合并到一个 dll 中,您可以在应用程序中引用该 dll。
您引用的实际母版页将具有如下类名称:MyMasterPage_aweknk,因此请在反射器中查找它。 看起来像“MyMasterPage”的类实际上只是隐藏代码。
这确实很恶心,但这就是我们在多个应用程序中重用用户控件所做的事情。
There are no pretty solutions to this problem.
What you can do is put it into a separate web application project and pre-compile it. Then take the precompiled dlls and ILMerge them into a single dll that you can reference in your app.
The actual master page that you reference will have a class name like this: MyMasterPage_aweknk so look it up in reflector. The class that looks like "MyMasterPage" is really just the code-behind.
It's really disgusting, but it's what we've done to reuse user controls in multiple applications.
Dan Wahlin 的跨 IIS 应用程序共享母版页给你一些想法..
另外,请查看 Scott Allen 的这篇 优秀文章。 您可以检查共享母版页末尾的最后一部分。
Sharing Master Pages Across IIS Applications by Dan Wahlin will give you some ideas..
Also, check this excellent article by Scott Allen. You can check the last section at the end on sharing master pages.
母版页基于用户控件,因此它们不能跨应用程序共享。
也就是说,Dan Wahlin 有办法解决这个特定的限制 博客。
Master Pages are based upon Usercontrols, therefore they cannot be shared across applications.
That said, Dan Wahlin has a way around that particular limitation listed on his blog.