简体   繁体   English

创建一个依赖于Umbraco母版页的“普通”ASP.NET页面

[英]Create a “normal” ASP.NET page which depends on an Umbraco master page

Is it possible in Umbraco to create a normal webforms page which inherits the main Umbraco master page? 在Umbraco中是否可以创建一个继承主要Umbraco母版页的普通webforms页面?

My client has a requirement for some complex functionality which needs to be done in a page outside the context of the CMS. 我的客户需要一些复杂的功能,需要在CMS的上下文之外的页面中完成。

I wonder whether it's possible to fire up the Umbraco context manually from within the constructor of a "normal" page. 我想知道是否可以从“普通”页面的构造函数中手动启动Umbraco上下文。 At the moment I just get the error: 目前我刚收到错误:

Exception of type 'System.Web.HttpUnhandledException' was thrown. 抛出了类型'System.Web.HttpUnhandledException'的异常。 ---> System.NullReferenceException: Object reference not set to an instance of an object. ---> System.NullReferenceException:对象引用未设置为对象的实例。 at umbraco.item..ctor(IDictionary elements, IDictionary attributes) at umbraco.presentation.templateControls.ItemRenderer.GetFieldContents(Item item) at umbraco.presentation.templateControls.ItemRenderer.ParseMacros(Item item) at umbraco.presentation.templateControls.Item.OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at at umbraco.item..ctor(IDictionary elements,IDictionary attributes)at umbraco.presentation.templateControls.ItemRenderer.GetFieldContents(Item item)at umbraco.presentation.templateControls.ItemRenderer.ParseMacros(Item item)at umbraco.presentation.templateControls.Item .OnInit(EventArgs e)位于System.Web.UI.Control.InitRecursive(Control namingContainer)的System.Web.UI.Control.InitRecursive(Control namingContainer)

thanks Kris 谢谢克里斯

You can use alternate templates to reference a template directly without having a Content Page associated with it. 您可以使用备用模板直接引用模板,而无需与其关联的内容页面。

You can reference it in these ways: 您可以通过以下方式引用它:

http://www.yourdomain.com/page.aspx?altTemplate=templatename http://www.yourdomain.com/page.aspx?altTemplate=templatename

http://www.yourdomain.com/page/templatename.aspx http://www.yourdomain.com/page/templatename.aspx

That would prevent users from deleting the node. 这将阻止用户删除节点。

Does that help? 这有帮助吗?

U can inherit from umbraco master pages specify your masterpages manually like this 你可以从umbraco母版页继承,像这样手动指定你的主页

MasterPageFile="../masterpages/umbracoPage.Master"

This works for an .aspx page where you are specifying this page in the plugin directory 这适用于.aspx页面,您在plugin directory中指定此页面

I think that you can achieve what you are asking; 我认为你可以实现你的要求;

The usual way to take a page out of the control of Umbraco is to use the web.config keys umbracoReservedUrls and umbracoReservedPaths - these are the keys installed with 4.11.1: 将页面从Umbraco控制中取出的通常方法是使用web.config键umbracoReservedUrls和umbracoReservedPaths - 这些是与4.11.1一起安装的键:

<add key="umbracoReservedUrls" value="~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd" />
<add key="umbracoReservedPaths" value="~/umbraco,~/install/" />

Secondly if your top level master page contains no umbraco items or macros or anything you can always switch to a masterpage during the Page PreInit event 其次,如果您的顶级母版页不包含umbraco项目或宏或任何内容,您可以在Page PreInit事件期间始终切换到母版页

protected void Page_PreInit(Object sender, EventArgs e)
{
    this.MasterPageFile = "/umbraco/masterpages/default.master";
}

Or you could use the technique that @BeaverProj outlines. 或者您可以使用@BeaverProj概述的技术。

EDIT 编辑

Looking at your comment I think that you can get at umbraco data without being in umbraco 'context'. 看看你的评论我认为你可以获得umbraco数据,而不是在umbraco'上下文'。 Add project references to cms.dll and businesslogic.dll (umbraco will have dropped them in the bin) and then you can use the umbraco framework without the wrapper controls. 添加对cms.dll和businesslogic.dll的项目引用(umbraco会将它们放入bin中),然后你就可以使用没有包装器控件的umbraco框架。 For example the internal editMacro.aspx page uses the framework directly: 例如,内部editMacro.aspx页面直接使用框架:

                <asp:DropDownList OnPreRender="AddChooseList" runat="server" ID="macroPropertyType"
                    DataTextFormatString="" DataTextField='macroPropertyTypeAlias' DataValueField="id"
                    DataSource='<%# GetMacroPropertyTypes()%>' SelectedValue='<%# ((umbraco.cms.businesslogic.macro.MacroPropertyType) DataBinder.Eval(Container.DataItem,"Type")).Id %>'>
                </asp:DropDownList>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM