OWIN, Attribute routing - always 404 and blank page

Topics: ASP.NET Web API
Feb 22, 2014 at 6:40 PM
I'm really have no more ways to try so asking here: I'm using web api 2.1 + OWIN in console app + built-in attribute routing. I have two projects, one is Host which starts either the console app or win service and run the second project's code that has all web api configuration and controllers.

Configuration:
var config = new HttpConfiguration();
config.MapHttpAttributeRoutes();
var builder = (IAppBuilder)HttpApplicationContext.AppBuilder;
builder.UseWebApi(config);
config.EnsureInitialized();

Controllers:
// 1 - derive from a custom apicontroller
[RoutePrefix("")]
public class ShellController : RazorApiController
{
public ShellController()
  : base("Shell")
{
}

[Route("", Name = "index"), HttpGet]
public IHttpActionResult Index()
{
  return View("Index");
}

[Route("", Name = "get"), HttpGet]
public IHttpActionResult Get()
{
  return View("Index");
}
}

// 2 - same as above but derived from ApiController
[RoutePrefix("")]
public class Shell3Controller : ApiController
{
public Shell3Controller()
{
}

[Route("", Name = "index"), HttpGet]
public IHttpActionResult Index()
{
  return null;
}

[Route("", Name = "get"), HttpGet]
public IHttpActionResult Get()
{
  return null;
}
}

// 3 - same but without attribute routing
public class Shell2Controller : ApiController
{
public Shell2Controller()
{
}

public IHttpActionResult Get()
{
  return null;
}
}

I places breakpoints in each controller methods so returning NULL is not a problem.
None of tried urls are working:
/api/*
/api/*/**
/*
/*/**
where * - is either shell, shell2 or shell3, ** - action name.
For any request I receive a blank page (not a NotFound browser page) and 404 error in the Chrome's Dev tools Network tab.

I've tried anything imaginable (event compiled and linked WebApi and OWIN from sources to be able to place breakpoints) with no luck.
Also, attached a TraceWritter and only see Operator=DefaultHttpControllerTypeResolver; OPerator=GetControllerTypes in console.

Please suggest how/what to do to track what went wrong.
Feb 23, 2014 at 5:51 PM
Issue is closed. My fault.
Coordinator
Feb 23, 2014 at 9:31 PM
Hey armsoft, just to followup (and for other folks to learn). Can you share the issue?
Feb 24, 2014 at 4:42 AM
Sure if it will help someone: I have a composite application with async loaded modules from different assemblies where WebApi is initialized. It's appeared that I've started the Owin host prior my [async] modules get loaded and initielized WebApi. It wasn's suspicious for me because in the Owin startup class I just created the HttpConfiguration instance while any other configuration happened in modules, including config.MapHttpAttributeRoutes(); appBuilder.UserWebApi(..) and config.EnsureInitialized().
So my thoughts were that Owin didn't finish its initialization until I call config.EnsureInitialized which was wrong.
It's appeared that all configuration should happen in the Owin startup class, not later. Any settings changes after that aren't reflected on WebApi routing/etc.
Maybe it's a bug or need to state that explicitly in bold on Wiki.