Reputation: 1197
I have created asp.net empty project in visual studio 2013 with c#. So whenever I tries to get any view I get error of Resource not found. However, If I create a internet application template project it works fine.
So here is my URL: http://localhost:43763/Home/About
Home Controller (Home.cs)
namespace MvcApplication1.Controllers
{
public class Home : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
public ActionResult About()
{
return View();
}
}
}
About View (About.cshtml)
@{
ViewBag.Title = "About";
}
<h2>About</h2>
Here is RouteConfig.cs
namespace MvcApplication1
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
}
Upvotes: 2
Views: 198
Reputation: 3182
Change your controller name from Home to HomeController .i think maybe this is the reason
The Controllers Folder contains the controller classes responsible for handling user input and responses.
MVC requires the name of all controllers to end with "Controller".
public class HomeController : Controller
{
}
Upvotes: 2