Question

I am writing a very basic setting to host a katana http Listener based application.

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();
    }
  }
}

When running this programm, I can access the port 5000, it even reaches a breakpoint within the owinMiddleWare I wrote. But its response is never closing and I cannot get the response in my browser.

What am I doing wrong ?

Was it helpful?

Solution

That seems to be working:

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);
  }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top