I'm just dipping into creating some custom middleware for owin, but when I run it, it's showing a 403.14 in the browser.
I created an empty WebProject, added an owin startup class like below
using System.Threading.Tasks;
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(OwinTest.Startup))]
namespace OwinTest {
public class Startup {
public void Configuration(IAppBuilder app) {
app.Use<MySimpleMiddleware>();
}
class MySimpleMiddleware : OwinMiddleware {
public MySimpleMiddleware(OwinMiddleware next) : base(next) { }
public override Task Invoke(IOwinContext context) {
context.Response.StatusCode = (int)System.Net.HttpStatusCode.OK;
context.Response.ContentType = "text/plain";
context.Response.Write("Hello, world.");
return base.Next.Invoke(context);
}
}
}
}
Which, when run in either IIS express (8), or IIS (7.5), it provides me with a HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
error.
However, if I change the final line of Invoke
to be return Task.FromResult(0);
, then it works as expected, but I don't know if I necessarily want to be terminating the pipeline at this point (or do I, if this is the primary
middleware?)