Reputation: 1340
Got some problems with my OWIN selfhost server. I'm trying to make it accessible through my local network. Which means the IP address of the host will be used to connect to the server. Bad thing is, I get a bad request, invalid hostname.
I've done some Googling and I found a possible solution regarding Startup Options:
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));
Now I've tried to implement that only to get a error:
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();
}
}
I originally did it with baseURL and then (url : baseAdress) with my startup. But now I get an error and my server stops running.
{"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'.":""}
Any idea what I'm doing wrong?
My original implementation doesn't work because I need to make the server accessible through my local network on other devices too. I think implementing these startupOptions may do the trick here.
I've already disabled my Firewall :)
Upvotes: 2
Views: 2114
Reputation: 970
Use this Url option, where 9095 is port number
options.Urls.Add("http://+:9095");
Check your firewall settings. Port 9095 should be accessible.
Upvotes: 5
Reputation: 116
Your ServerTestApp.Program
requires a Configuration
method.
This is the convention that you must follow.
public void Configuration(IAppBuilder app)
{
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
}
Upvotes: 3