0

我正在尝试将 DNN6 站点地图提供程序公开给外部 asp.net 应用程序。

有没有人有任何有用的提示来完成这个?

我可以毫无问题地获取用户和选项卡属性;并在 asp.net 应用程序中为基本 URL 创建了一个节点,帮助?

我创建了一个 DNN Web 服务,我的应用程序将调用它来在 asp.net 旧版应用程序上正确设置导航(使用 DNN 来维护导航和权限)。

4

1 回答 1

0

Here's the full code of a handler that retrieves tabs in hierarchy from the DNN database and returns the result as an xml document. It's a child's play to wrap any sitemap provider around the xml.

<%@ WebHandler Language="C#" Class="Menus" %>

using System;
using System.Web;


using System.Text;
using System.Xml;
using System.IO;
using System.Globalization;

using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Tabs;
using DotNetNuke.Security.Permissions;
using System.Collections.Generic;


public class Menus : IHttpHandler {

public void ProcessRequest (HttpContext context) {



string cc = PortalAliasController.GetPortalAliasByTab(Int32.Parse(context.Request.Params["tabid"]),"");

PortalAliasInfo pa = PortalAliasController.GetPortalAliasInfo(cc);
int portalid = pa.PortalID;


PortalSettings ps = new PortalSettings(portalid);
int tabid = ps.HomeTabId;  

if (!String.IsNullOrEmpty(context.Request.Params["tabid"]))
    tabid = Int32.Parse(context.Request.Params["tabid"]);  


XmlWriterSettings ws = new XmlWriterSettings();
ws.Indent = true;
ws.Encoding = Encoding.UTF8;
    XmlWriter xw = XmlWriter.Create(context.Response.OutputStream, ws);
    context.Response.ContentType = "text/xml";


xw.WriteStartElement("root");
xw.WriteElementString("portalid", portalid.ToString());


MakeMenu(context, xw, tabid, portalid);

xw.WriteEndElement();
xw.Close();


}

public bool IsReusable {
    get {
        return false;
    }
}


private void MakeMenu(HttpContext context, XmlWriter xw, Int32 tabid, Int32 portalid)
{



    List<TabInfo> tabs = TabController.GetTabsByParent(tabid, portalid);
    if (tabs.Count == 0) return;




    foreach (TabInfo objTab in tabs)
    {


        if (!objTab.IsDeleted &&
          !objTab.DisableLink &&
          objTab.IsVisible &&
          objTab.TabType == TabType.Normal &&
          (Null.IsNull(objTab.StartDate) || objTab.StartDate < DateTime.Now) &&
          (Null.IsNull(objTab.EndDate) || objTab.EndDate > DateTime.Now)

        )
        {
            if (TabPermissionController.CanViewPage(objTab))
            {


                string tabName = objTab.TabName;
                string URL = objTab.FullUrl;

              if (URL.ToLower().IndexOf(context.Request.Url.Host.ToLower()) == -1) ;

              URL = Globals.AddHTTP(context.Request.Url.Host) + URL;


              xw.WriteStartElement("menu");
              xw.WriteAttributeString("text", tabName);
              xw.WriteAttributeString("url", URL);
              MakeMenu(context, xw, objTab.TabID, portalid);
              xw.WriteEndElement();

            }

        }


    }


}

}

于 2013-01-25T18:10:10.247 回答