Reputation: 835
While i was trying to port a owin asp.net website to the pi, (raspberry pi model b) I ended up with a website displaying the error page :
Bad Request (Invalid host)
On the pi i am running raspbian wheezy. I installed mono (version 3.2.8).
For a simple console aplication mono works.
for the Owin website i made a console project in visual studio 2015.
To this console aplication i added the nuget packages :
Microsoft.Owin
Microsoft.Owin.Diagnostics
Microsoft.Owin.Host.HttpListner
Microsoft.Owin.Hosting
public void Configuration(IAppBuilder app)
{
app.UseWelcomePage(new Microsoft.Owin.Diagnostics.WelcomePageOptions()
{
Path = new PathString("/welcome")
});
app.Run(context =>
{
context.Response.ContentType = "text/plain";
string output = string.Format(
"I'm running on {0} nFrom assembly {1}",
Environment.OSVersion,
System.Reflection.Assembly.GetEntryAssembly().FullName
);
return context.Response.WriteAsync(output);
});
}
Now i only needed to specify the base url of the project within the program class, id did this in the main function
string baseUrl = "http://localhost:5000";
using (WebApp.Start<Startup>(baseUrl))
{
Console.WriteLine("Press Enter to quit.");
Console.ReadKey();
}
With this code my project gives on startup a console view with the text
Press Enter to quit.
When i browse to
The webpage gives the folowing output:
I'm running on Microsoft Windows NT 6.2.9200.0 nFrom assembly ConsoleApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
however when I copy all my dll's and exe to my pi and execute the command
Mono ConsoleApplication1.exe
the pi gives the line Press Enter to quit. but when i browse to the ip of the pi with the port number 500, in my case
The webpage displayes Bad Request (Invalid host)
Upvotes: 4
Views: 2456
Reputation: 835
The problem was in the direction rtf_leg pointed me the localhost is not available when accecsing the website from the pi.
i only had to change the base url to the exact url of the pi. in my case http://192.168.7.137:5000.
this way the pi knew what to do when the url was accesed and the rusult shown was :
I'm running on Unix 3.18.7.0 nFrom assembly ConsoleApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
:D
Upvotes: 0