【问题标题】:Using Umbraco Content on an existing .net site在现有 .net 站点上使用 Umbraco 内容
【发布时间】:2013-01-22 16:04:28
【问题描述】:

我想将 Umbraco 用作我现有 .net 网站的 CMS。 我已经翻阅了所有 Umbraco 教程/Wiki 文章,并得出结论,在我的代码中通过 Umbraco DLL 使用 NodeFactory 是前进的方向。

但是,所有文章/wiki/社区帮助都假定您的 Umbraco 安装已经是您现有站点的一部分。 在我的情况下,我需要将我的站点直接引用到新的 Umbraco 安装,这是将设置(例如数据库连接字符串等)从 Umbraco Web.Config 导入我的站点 Web.Config 的简单案例还是存在从 Umbraco 安装中提取内容而不是现有站点的一部分的更好方法?

【问题讨论】:

    标签: .net umbraco


    【解决方案1】:

    取决于您需要什么内容。我建议创建一些基本的 Web 服务来提供一个 API,以便从 umbraco 站点访问您的数据。 Umbraco 提供了基本的其余扩展,使您可以轻松地建立 Web 服务。但您也可以连接 ashx 文件或类似文件。我在 umbraco 网站上使用 odata 取得了成功。

    【讨论】:

    • 谢谢,我会看看这个选项 - 我们实际上是在使用 Umbraco 为我们的网站创建内容,而不是真正使用它来构建网站
    【解决方案2】:

    您想查看 Umbraco /Base - 更多详细信息请参见以下网址以及此处引用的其他页面,了解如何使用 Umbraco /Base:

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

    【讨论】:

      【解决方案3】:

      我们为此使用了自定义 404 处理程序。 ASP.NET 网站将处理该请求,而不是返回 404,然后将在内容站点上查找相同的路径。如果内容存在,我们将返回该页面。如果不是,我们返回 404 错误。

      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

      【讨论】:

      • 谢谢 Rob,我也去看看
      猜你喜欢
      • 2016-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-10
      相关资源
      最近更新 更多