简体   繁体   English

在现有.net网站上使用Umbraco内容

[英]Using Umbraco Content on an existing .net site

I would like to use Umbraco as a CMS for my existing .net website. 我想将Umbraco用作现有.net网站的CMS。 I have shifted through all the Umbraco tutorials / Wiki articles and have come to the conclusion that using the NodeFactory via the Umbraco DLL's in my code is the way forward. 我浏览了所有Umbraco教程/ Wiki文章,得出的结论是,通过代码中的Umbraco DLL使用NodeFactory是前进的方向。

However all articles/wiki/community help assume that your Umbraco installation is already a part of your existing site. 但是,所有文章/ Wiki /社区帮助都假定您的Umbraco安装已经是您现有站点的一部分。 In my case I need to reference my site directly to the new Umbraco installation, is this a simple case of importing the settings (such as DB connection string etc..) from the Umbraco Web.Config into my sites Web.Config or is there a better way to pull the content from an Umbraco installation without it being part of an existing site? 就我而言,我需要直接将我的站点引用到新的Umbraco安装,这是将设置(例如DB连接字符串等)从Umbraco Web.Config导入到我的站点Web.Config中的简单情况吗?有更好的方法从Umbraco安装中提取内容而不将其作为现有站点的一部分吗?

Depending on what content you need. 根据您需要的内容。 I would suggest creating some basic web services to provide an API for accessing your data from the umbraco site. 我建议创建一些基本的Web服务,以提供用于从umbraco网站访问您的数据的API。 Umbraco provides the base rest extensions that allow you to put up a web service easily. Umbraco提供了基础休息扩展程序,使您可以轻松地建立Web服务。 But you could also hook up an ashx file or something similar. 但是您也可以连接ashx文件或类似文件。 I've had success using odata with an umbraco site. 我已经成功地在umbraco网站上使用了odata。

You want to look at Umbraco /Base - more detail at the following url and the other pages referenced from here on how to work with Umbraco /Base: 您想看一下Umbraco / Base-有关以下网址的更多详细信息,以及从此处引用的有关如何使用Umbraco / Base的其他页面:

http://our.umbraco.org/wiki/reference/umbraco-base http://our.umbraco.org/wiki/reference/umbraco-base

We used custom 404 handlers for this. 为此,我们使用了自定义404处理程序。 The ASP.NET website would handle the request and rather than a 404 being returned, the same path would then be looked for on the content site. ASP.NET网站将处理该请求,而不是返回404,然后在内容站点上查找相同的路径。 If content existed we return that page. 如果内容存在,我们将返回该页面。 If not, we return the 404 error. 如果不是,我们返回404错误。

MVC example MVC示例

[DefaultAction("index")]
public class RescuesController : SmartDispatchController
{
    private static readonly Regex headtitleRegex = new Regex("<h1>([^<]*)</>>");

    public RescuesController(IApplicationContextProvider currentCustomerProvider, IConfigurationManager configurationManager) : base(currentCustomerProvider, configurationManager) { }

    public void Index()
    {
        RenderView("rescues","content");

        string pageName = Request.Uri.LocalPath;
        if (pageName.EndsWith("/index"))
            pageName = pageName.Substring(0, pageName.LastIndexOf("/index"));

        try
        {
            var remoteContent = GetRemoteContent(pageName);

            var matches = headtitleRegex.Match(remoteContent);
            if (matches.Groups.Count > 1)
                PropertyBag.HeadTitle = matches.Groups[1].Captures[0].Value;

            PropertyBag.remoteContent = headtitleRegex.Replace(remoteContent, "");
        } catch (WebException) {
            Handle404();
        }
    }

    public static string GetRemoteContent(string pageName)
    {
        return (new WebClient()).DownloadString("http://content.mysite.com/" + pageName);
    }
}

http://www.robertgray.net.au/posts/2010/4/404-handlers http://www.robertgray.net.au/posts/2010/4/404-handlers

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

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