ASP.Net MVC – Resource Cannot be found error
Make sure you created a HomeController.cs class in your controller folder.
URL mapping or "routing" is handled by Global.asax in the root of your ASP.NET MVC site.
When you click "Set as Start Page" it changes the project settings to look for that file relative to the application root. But in MVC the default route to your index page is actually http://localhost:4163/Home/Index
- read something like this to get an idea of how routing works.
To "fix" your project now that it's trying (and failing) to navigate to the view directly, right click the project and choose "Properties
", click the "Web
" tab and choose "Specific Page
", leaving the text box blank. Now when you start to debug it should go to the home page again - look at the default route parameters to see why in the RegisterRoutes method in Global.asax
Unbelievably, I'd accidentally deleted the public keyword from the controller!
I imagine this will help precisely no one else, but you never know ...
In a similar issue I faced, my Action had an HTTP "POST" attribute, but I was trying to open the page (by default it's "GET").
So I had to create an HTTP "GET" version.