2

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 }
            );
        }
    }
}

1 Answer 1

2

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
    {

    }
Sign up to request clarification or add additional context in comments.

1 Comment

Yep. All controller classes need to end with Controller.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.