As you are already aware, OwinContext consumed by Startup.Configuration() is different from the traditional ASP.NET HttpContext consumed by MvcApplication.Application_Start(). Both are using different context pipelines. More specifically, ASP.NET MVC still relies on System.Web.dll while ASP.NET Web API doesn’t.
Therefore, based on your code, some methods usually laid in MvcApplication.Application_Start() can’t be run within Startup.Configuration():
AreaRegistration.RegisterAllAreas();: This method relies onSystem.Web.dll.RouteConfig.RegisterRoutes(RouteTable.Routes);:RouteCollectionis a part ofSystem.Web.dll.GlobalConfiguration.Configure(WebApiConfig.Register): Again,RouteCollectionwithinWebApiConfig.Register()is a part ofSystem.Web.dll.
For URL routing within OWIN context, AttributeRouting is recommended. So, instead of this, try config.MapHttpAttributeRoutes(); That will give you much freedom.
If you still want to run AreaRegistration.RegisterAllAreas(); within OWIN context, Startup.Configuration(), I’d better recommend to import Katana library. This integrates OWIN with System.Web.dll so that you probably archieve your goal.
HTH