这是我的测试代码:
public class MyModule : NancyModule
{
public MyModule()
{
Get["/resources/{resourceId}"] = x =>
{
var kurt = (string)x.resourceId;
return Response.AsText(kurt);
};
}
}
class Program
{
static void Main(string[] args)
{
using (var host = new NancyHost(new Uri("http://localhost:1234")))
{
host.Start();
Console.WriteLine("Running on http://localhost:1234");
Console.ReadLine();
}
}
}
当我从VS运行它时,它按预期工作,但是当我使用mono.exe托管.exe时,我在浏览器中得到了这个:
P/1.1 200 OK
Content-Type: text/plain
Server: Mono-HTTPAPI/1.0
Date: Fri, 07 Oct 2016 10:58:32 GMT
Transfer-Encoding: chunked
Keep-Alive: timeout=15,max=100
4
test
0
似乎浏览器理解响应头。但为什么呢?