Reputation: 10402
I am working on an ASP.NET MVC3 application.
In the Views I created a folder named Home and a View named Index.
Then I created a Controller HomeController.
In the Controller I added:
public ActionResult Index()
{
return View();
}
but when I run the application I get this error:
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: /
If I add to the address bar : /Home/Index the view loads normally.
How can I make the application automatically go to Home/Index when it loads?
Thanks for any help
Upvotes: 0
Views: 411
Reputation: 851
You need to add a route to the Global.asax file that points to your path.
routes.MapRoute("Default", "{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Upvotes: 1