2 services (WCF Web API and ASP.NET Web API) on one host

Topics: Web Api
Oct 20, 2014 at 11:44 AM
Preconditions:

1) local DB with users

2) console application (OWIN selfhost) + Controller (inherit from ApiController) for POST requests - import users to the DB:
public class Startup
{

      public void Configuration(IAppBuilder appBuilder)

      {

            var config = new HttpConfiguration();

            config.MapHttpAttributeRoutes();

            appBuilder.UseWebApi(config);

      }

}



public class Start

{
      static void Main()
      {
            var baseUrl = ConfigurationManager.AppSettings["BaseUrl"];

            using (WebApp.Start<Startup>(baseUrl))

            { Console.ReadLine(); }

      }
}
Problem: how can I add a WCF service to the app (wcf service should return user from the DB by ID). Can anybody suggest right solution to get 2 services on one selfhost?
Oct 22, 2014 at 7:04 AM
static void Main()
        {
            var baseUrl = ConfigurationManager.AppSettings["BaseUrl"];
            AppDomain.CurrentDomain.SetData("DataDirectory", ConfigurationManager.AppSettings["DbLocation"]);

            using (WebApp.Start<Startup>(baseUrl))
            {
                Console.WriteLine("OWIN host started");
                using (var host = new ServiceHost(typeof(GetProfileService)))
                {
                    host.Open();
                    Console.WriteLine("ServiceHost started");
                    Console.ReadLine();
                    host.Close();
                }
            }
        }
Marked as answer by sevine on 10/22/2014 at 12:04 AM