如何在Consul中注册MVC .net应用程序

时间:2019-06-19 13:37:27

标签: c# consul

我已经在IIS中托管了.net MVC应用程序。我正在尝试使用以下代码从控制台应用程序将IIS应用程序注册到Consul服务,

using Consul;
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                var registration = new AgentServiceRegistration
                {

                    Name = "ConsultationEngine",
                    Port = 8091,
                    Address = "127.0.0.1"
                };

                using (var client = new ConsulClient())
                {
                    client.Agent.ServiceRegister(registration);
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}

成功运行此代码服务后,未注册。 Consul是否仅支持Asp.net Core Applciation?

0 个答案:

没有答案