asp.net-coreasp.net-core-mvc

404 error for any action with asp.net core MVC


With a brand new project created from scratch (not a Visual Studio template), using Kestrel for the server, and a very simple Startup.cs that just initializes MVC with services.AddMvc(); and app.UseMvc();, any request to a controller action returns a 404 error instead of running the action.


Solution

  • Turns out there was a typo in my project.json.

    This compiles but does not work: "Microsoft.AspNetCore.MVC": "1.0.0-rc2-final",

    This works fine: "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",

    Don't see the difference? Took me quite a while to find it. The version that does not work is using uppercase MVC, while the correct version is Mvc. Why it compiles but silently fails at runtime is a mystery for me though.