This project has moved and is read-only. For the latest updates, please go here.


May 7, 2014 at 1:58 PM
I am facing an issue when using SystemWeb. I will explain it below step by step:
  1. Create Empty Project in VS 2013
  2. Install the SystemWeb package
  3. Create a Startup class with designated assembly attributes
  4. Add the following:
app.Use(async (ctx, next) => {
    await ctx.Response.WriteAsync("Hello World!);
    await next();
  1. Hit F5 to run the application
An HTTP Error 403.14 Forbidden exception is thrown.

If I simply remove "await next()" or add another "app.Run()", things works fine.

Is this a bug? If no "next" in the pipeline, an exception is thrown?

May 7, 2014 at 5:20 PM
Side note: You should not both write to the stream and call next. Only call next if you're not done processing the request.

On SystemWeb calling next will eventually reach the end of the OWIN pipeline and go back into IIS. In IIS you are hitting a resource that is returning Forbidden. However, when you added Run that terminated the OWIN pipeline before the request reached IIS.

Here's what you actually want for Hello World:
app.Run(async ctx => {
    await ctx.Response.WriteAsync("Hello World!);
May 7, 2014 at 10:03 PM
Thanks for the reply.

From what I learned, OWIN pipeline hooks into HttpModule events to process requests. So let me get it straight, once a request is handled by OWIN, what happens next? Isn't the response sent back to IIS to send it back to client? Maybe some explanation here on the life cycle of an OWIN request would help a lot!

May 7, 2014 at 10:11 PM
Consider these scenarios:

Request handled in OWIN pipeline:
IIS -> ASP.NET -> OWIN pipeline
IIS <- Aps.Net <- Response generated

Request not handled in OWIN pipeline:
IIS -> ASP.NET -> OWIN pipeline -> ASP.NET -> IIS
IIS <- ASP.NET <- IIS <- Response generated
May 7, 2014 at 10:16 PM
So if OWIN generates a response, it must be setting the ContentType to some valid code thats why IIS doesnt touch the response. While if OWIN didnt handle the request, IIS is forced to generate a response?

Can you guide me in which code file I can see this in action?

Many thanks,

May 7, 2014 at 10:22 PM
Right, if OWIN doesn't generate a response then IIS has to.

Here's the code, but it's not an easy read:
Marked as answer by Tratcher on 5/21/2014 at 2:10 PM
May 7, 2014 at 10:25 PM
Many thanks.