Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nikolas van Etten 202 posts 162 karma points
    Jun 03, 2010 @ 14:43
    Nikolas van Etten
    0

    get hostname(s)

    I need to check the assigned hostname(s) in a datatype.

    Any simple way of getting this?

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jun 03, 2010 @ 14:46
    Lee Kelleher
    1

    There is an API method to get all the domains for the current page/node:

    umbraco.library.GetCurrentDomains(int NodeId)

    Cheers, Lee.

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jun 03, 2010 @ 14:48
    Lee Kelleher
    2

    or if you want all the domains, then try the following method:

    umbraco.cms.businesslogic.web.Domain.GetDomains()

    That will return a List<Domain> collection.

    Cheers, Lee.

  • Nikolas van Etten 202 posts 162 karma points
    Jun 03, 2010 @ 14:49
    Nikolas van Etten
    0

    Thanks for your extremely quick reply Lee!

    Nik

  • mahesh 12 posts 34 karma points
    Mar 22, 2011 @ 06:06
    mahesh
    0

    Hi Lee,

     

      I can't find a method like Domain.GetDomains() in umbraco.cms.businesslogic.web.

     

     

    Mahesh

  • Daniel Bardi 927 posts 2562 karma points
    Mar 22, 2011 @ 08:47
    Daniel Bardi
    1

    GetDomains() is an internal method.

    Here's the code:

    internal static List<Domain> GetDomains()
    {
        return Cache.GetCacheItem<List<Domain>>("UmbracoDomainList", getDomainsSyncLock, TimeSpan.FromMinutes(30.0), delegate {
            List<Domain> list = new List<Domain>();
            using (IRecordsReader reader = SqlHelper.ExecuteReader("select id, domainName from umbracoDomains", new IParameter[0]))
            {
                while (reader.Read())
                {
                    string domainName = reader.GetString("domainName");
                    int id = reader.GetInt("id");
                    if (list.Find(d => d.Name == domainName) == null)
                    {
                        list.Add(new Domain(id));
                    }
                    else
                    {
                        Log.Add(LogTypes.Error, User.GetUser(0), -1, string.Format("Domain already exists in list ({0})", domainName));
                    }
                }
            }
            return list;
        });
    }
Please Sign in or register to post replies

Write your reply to:

Draft