How and when does Configuration method in OwinStartup class is called/executed?

It's a little bit late, but I found the solution how to put OWIN Startup class in separate project. Everything you did in your project is correct, you must only apply one change in the properties of your Bootstrapper project. Right click on Bootstrapper project, enter properties, click Build tab and look for Output path. You should see standard output path bin\debug\ which means that your Bootstrapper dll will land in this folder. You must change this to the bin folder, where your whole web app is.

For example, I've created a simple solution with two projects, first is an empty web app, and the second is a library with an OWIN Startup class. In properties of the second project I've changed the output path to ..\OwinTest.Web\bin. This will cause all dlls to land in one folder after the build. You can now run your app and OWIN Startup should work right.

Below is the screen of properties settings of Bootstrapper project:

enter image description here


  1. Create an empty web application project
  2. Install the OWIN using NuGet (install-package Microsoft.Owin.Host.SystemWeb)
  3. Add an empty class into the project root called "Startup.cs"

Here I will answer your third question. The startup class is an entry point of OWIN and is being looked up automatically. As stated in official docs:

Naming Convention: Katana looks for a class named Startup in namespace matching the assembly name or the global namespace.

Note, that you can also choose your own name of Startup class but you have to set this up using decorators or AppConfig. As stated here: https://www.asp.net/aspnet/overview/owin-and-katana/owin-startup-class-detection

This is everything you need for a basic and working OWIN test:

using Owin;
using System;

namespace OwinTest
{
    public class Startup
    {
        public static void Configuration(IAppBuilder app)
        {
            app.Use(async (ctx, next) =>
            {
                await ctx.Response.WriteAsync(DateTime.Now.ToString() + " My First OWIN App");
            });
        }
    }
}

If you wish to use MVC (I guess by "Home/Index" you mean MVC), follow these steps:

  1. Install MVC NuGet (install-package Microsoft.AspNet.Mvc).
  2. Add a "Controllers" folder into your project.
  3. Create a new empty controller under the new "Controlles" folder (right click -> add -> MVC 5 Controller - Empty) and name it "HomeController".
  4. Create a view page under newly created "Views/Home" folder. Right click -> add -> View. Name it "Index" and uncheck the "use layour page".

Make the page inherit from WebViewPage. It should all look like this:

@inherits System.Web.Mvc.WebViewPage
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
    <div> 
        <h1>Owin Hello</h1>
    </div>
</body>
</html>
  1. Add a global.asax to set up routes. Right click on the project -> add -> New Item -> Global Application Class.

Add the routes definition to the Application_Start method:

protected void Application_Start(object sender, EventArgs e)
{
    RouteTable.Routes.MapRoute(name: "Default",
        url: "{controller}/{action}",
        defaults: new { controller = "Home", action = "Index" });
}
  1. Do not forget to comment out the above "..await ctx.Response.WriteAsync..." middleware. It would interfere with the MVC otherwise.
  2. Run the project. Should be working.