CorBins
Member
With Visual Studio, I created a console application with api (8 apiControllers). On my local machine, it works fine. On the machine of my colleague also no problem. When copying the exe-file to a WindowsServer2012R2, there's a problem. The api listens to port 44311. The exe is running. When looking with netstat, I see port 44311 is listening. But, when trying to get some answer in a browser, nothing appears (in the browser, I've to enter the url https://localhost:44311/BitVise/Test). The API has a swagger, but in the browser, the swagger also returns nothing but the error 'this site is not available'.
Some code: Program.cs:
Startup.cs:
Beginning of BitViseController.cs:
Image showing the console app is running, listening and the browser showing the error.
Does anyone have an idea what I have forgotten or what I am doing wrong?
Thanks in advance,
Cor
Some code: Program.cs:
C#:
using System;
using System.Configuration;
namespace BitViseApi
{
class Program
{
static void Main(string[] args)
{
string domainAddress = ConfigurationManager.AppSettings["domainAddress"];
using (WebApp.Start(url: domainAddress))
{
Console.WriteLine("Service Hosted " + domainAddress);
System.Threading.Thread.Sleep(-1);
}
}
}
}
C#:
using Owin;
using System.Web.Http;
namespace BitViseApi
{
class Startup
{
public void Configuration(IAppBuilder appBuilder)
{
HttpConfiguration config = new HttpConfiguration();
config.EnableCors();
config.Routes.MapHttpRoute(
name: "createUserApi",
routeTemplate: "Bitvise/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
SwaggerConfig.Register(config);
appBuilder.UseWebApi(config);
}
}
}
Beginning of BitViseController.cs:
C#:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Web.Http;
using System.Web.Http.Cors;
using BssCfg815Lib;
using System.Security.Cryptography;
using System.Text;
using NLog;
namespace BitVise
{
[EnableCors(origins: "*", headers: "*", methods: "*")]
public class TestController : ApiController
{
public string Get()
{
return "BitViseAppi is working";
}
} // TestController
public class VirtAccountsController : ApiController
{
public IEnumerable<LocalVirtAccount815> Get(string username, string password)
{
string result;
BitViseHelper helper = new BitViseHelper();
helper.Log(LogLevel.Info, "Call to VirtAccounts. Login: username=" + username + ", password=" + password);
bool loginOkay = helper.CheckUser(username, password, out result);
if (!loginOkay)
{
helper.Log(LogLevel.Error, " Login failed: " + result);
return null;
}
helper.Log(LogLevel.Info, " Login succeeded.");
List<LocalVirtAccount815> virtAccounts = helper.ListVirtAccounts();
helper.Log(LogLevel.Info, " " + virtAccounts.Count + " Virtual accounts retrieved.");
return virtAccounts;
}
} // VirtAccountsController
...
Does anyone have an idea what I have forgotten or what I am doing wrong?
Thanks in advance,
Cor
Last edited: