C# Katana中的HttpListener不发送响应
我正在编写一个非常基本的设置来托管基于katana http侦听器的应用程序C# Katana中的HttpListener不发送响应,c#,owin,katana,C#,Owin,Katana,我正在编写一个非常基本的设置来托管基于katana http侦听器的应用程序 public class MyMiddleWare : OwinMiddleware { public MyMiddleWare(OwinMiddleware next) : base(next) {} public override Task Invoke(IOwinContext context) { return new Task(() => context.Response.
public class MyMiddleWare : OwinMiddleware
{
public MyMiddleWare(OwinMiddleware next)
: base(next) {}
public override Task Invoke(IOwinContext context)
{
return new Task(() => context.Response.Write("Hello world!!"));
}
}
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.Use<MyMiddleWare>();
}
}
class Program
{
static void Main(string[] args)
{
const string baseUrl = "http://localhost:5000/";
using (var server = WebApp.Start<Startup>(new StartOptions(baseUrl)))
{
Console.WriteLine("Press Enter to quit.");
Console.ReadKey();
}
}
}
公共类MyMiddleWare:OwinMiddleware
{
公共MyMiddleWare(OwinMiddleware下一步)
:base(next){}
公共覆盖任务调用(IOwinContext上下文)
{
返回新任务(()=>context.Response.Write(“helloworld!!”));
}
}
公营创业
{
公共无效配置(IAppBuilder应用程序)
{
app.Use();
}
}
班级计划
{
静态void Main(字符串[]参数)
{
常量字符串baseUrl=”http://localhost:5000/";
使用(var server=WebApp.Start(newstartoptions(baseUrl)))
{
控制台。WriteLine(“按Enter键退出”);
Console.ReadKey();
}
}
}
当运行这个程序时,我可以访问端口5000,它甚至可以到达我编写的owinMiddleWare中的断点。但它的响应永远不会关闭,我无法在浏览器中获得响应
我做错了什么?这似乎在起作用:
public class MyMiddleWare : OwinMiddleware
{
public MyMiddleWare(OwinMiddleware next)
: base(next) {}
public override Task Invoke(IOwinContext context)
{
context.Response.Write("Hello world!!");
return Next.Invoke(context);
}
}
Katana/OWIN文档的状态令人沮丧!非常感谢。应该这样做。