【发布时间】:2014-09-05 20:51:42
【问题描述】:
我有以下使用 Owin SelfHost 托管 webapi 的简单控制台应用程序。控制台本身的响应有效,但如果从提琴手尝试,我只是连接到本地主机失败。 (与浏览器相同)。
class Program
{
static void Main()
{
string baseAddress = "http://localhost:34300/";
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("da-dk");
// Start OWIN host
using (WebApp.Start<Startup>(url: baseAddress))
{
// Create HttpCient and make a request to api/values
HttpClient client = new HttpClient();
var response = client.GetAsync(baseAddress + "api/GpsPositions").Result;
Console.WriteLine(response);
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
Console.WriteLine("Listening on " + baseAddress);
}
Console.ReadLine();
}
}
我错过了什么吗?
【问题讨论】:
标签: asp.net-web-api owin