错误的响应,OWIN服务器中的启动选项
问题描述:
我的OWIN自主服务器出现了一些问题。我正试图通过我的本地网络访问它。这意味着主机的IP地址将用于连接到服务器。糟糕的是,我得到一个错误的请求,无效的主机名。错误的响应,OWIN服务器中的启动选项
我做了一些谷歌搜索,我发现关于启动选项一个可能的解决方案:
StartOptions options = new StartOptions();
options.Urls.Add("http://localhost:9095");
options.Urls.Add("http://127.0.0.1:9095");
options.Urls.Add(string.Format("http://{0}:9095", Environment.MachineName));
现在我试图执行只得到一个错误:
static void Main()
{
string baseAddress = "http://localhost:4004/";
/*Render application
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrontVorm());
*/
// Start OWIN host
StartOptions options = new StartOptions();
options.Urls.Add("http://localhost:4004");
options.Urls.Add("http://127.0.0.1:4004");
options.Urls.Add(string.Format("http://{0}:4004", Environment.MachineName));
using (WebApp.Start<Program>(options))
{
// Create HttpCient and make a request to api/values
HttpClient client = new HttpClient();
}
}
我原本用baseURL做了,然后用我的启动(url:baseAdress)。但是现在我得到一个错误,我的服务器停止运行。
{"The following errors occurred while attempting to load the app.\r\n - No 'Configuration' method was found in class 'ServerTestApp.Program, ServerTestApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.":""}
任何想法我做错了什么?
我的原始实施不起作用,因为我需要通过我的本地网络在其他设备*问服务器。我认为在这里实施这些启动选项可能会有所斩获。
我已经停用了防火墙:)
答
你ServerTestApp.Program
需要Configuration
方法。 这是您必须遵循的惯例。
public void Configuration(IAppBuilder app)
{
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
}
答
-
使用此URL选项,其中9095是端口号
options.Urls.Add("http://+:9095");
- 检查防火墙设置。端口9095应该可以访问。
几天前我已经开始工作了。有一些观点。 – 2015-02-25 09:17:58