I'm using an OWIN-based command line Self-Host app, and the new attribute routes work great for my Web API controllers. However, they don't appear to work for my regular MVC controllers.
I've tried mapping the routes the old way with a route template in my start method, and I've also tried doing it with attribute routes. Either way, I get 404 when I try to hit those routes.
In my start code I call the IAppBuilder.UseWebApi(...) extension method defined in Owin.WebApiAppBuilderExtensions class, but I didn't see an equivalent for MVC, something like UseMvc(...). Can they coexist? Am I missing something obvious?
Here's my start code:
var config = new HttpConfiguration();
config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter(Startup.OAuthOptions.AuthenticationType));
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
config.MapHttpAttributeRoutes();
app.UseCookieAuthentication(CookieOptions);
app.UseExternalSignInCookie(CookieAuthenticationDefaults.ExternalAuthenticationType);
app.UseOAuthBearerTokens(OAuthOptions, ExternalOAuthAuthenticationType);
app.UseFacebookAuthentication(appId: "12345", appSecret: "abcdef");
app.UseWebApi(config);
And here's my plain old MVC class:
[RoutePrefix("Home")]
public class HomeController : Controller
{
[HttpGet("Index")]
public ActionResult Index()
{
return Content("Hello world!", "text/plain");
}
}
When I hit /Home/Index
on my app, I get 404.