jjhayter
jjhayter

Reputation: 390

Debugging Self Host OWIN Middleware does not always run

I have a simple console app to learn OWIN/Katana and I am stuck.

class Program
{
    static void Main(string[] args)
    {
        string url = ConfigurationManager.AppSettings["url"];
        using (var app = WebApp.Start<Startup>(url))
        {
            Console.WriteLine("Started listening on {0}", url);
            Console.ReadKey();
            Console.WriteLine("Stopping");
        }
    }
}

This starts up just fine and hits my using block. Console fired up ready to listen to requests

I then see that my Startup is called: Use() Methods are being hit during debugging

Next I startup Postman in Chrome and submit a GET Request. At this point my break points never get hit in either module. Postman GET setup

No matter what changes I make it does not log my messages out to the console. Is there a way to find what is failing if anything? In Postman I do receive a HTTP 200 with a payload. The OwinMiddleware class is from the Microsoft.Owin namespace.

Owin Middleware Module Components

EDIT: Tech stack of the Project:

Website (Not Web Application) running AngularJs 1.4 using $resource. WebApi 2.2 with OData V4

Running on .Net 4.5

Upvotes: 1

Views: 2041

Answers (1)

Angel Yordanov
Angel Yordanov

Reputation: 3282

Your WebApiMiddleware is before the LoggingMiddleware in the pipeline so the request may have been terminated there and may never reach the logging. Add the logging on top, before StartupPrerequsites(app); and try again.

Upvotes: 1

Related Questions