문제

im not sure what i messed up, but i just keep getting the following error upon f5.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /

The following is my route, totally default and no changes.

        public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

    }

I have checked my project properties -> web tab, "Specific page" has nth. My project has Home folder with Index page.

Other pages are working only after manually inputting URL. For eg: http://localhost:21183/store/search

Thanks

도움이 되었습니까?

해결책

Things to check:

  1. You have a public class named HomeController that derives from Controller.
  2. This HomeController class has a public Index action.
  3. You have a corresponding view ~/Views/Home/Index.cshtml
  4. You are testing this inside a web server which supports extensionless urls. For example this won't work out of the box in IIS 6.0.

Controller:

public class HomeController: Controller
{
    public ActionResult Index()
    {
        return View();
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top