Click here to Skip to main content
11,927,324 members (51,312 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET
I am new to MVC web development so I am trying to discover this pattern.
I tried to create a new MVC application that navigate between pages.So I create 3 views (home,product,about) and a controller (Site)"The example is taken from the last lab Learn MVC (Model view controller) Step by Step in 7 days – Day 2[^]

code of the controller:

public class SiteController : Controller
       // GET: /Site/
       public ActionResult GoTohome()
           return View("Home");
       public ActionResult AboutUs()
           return View("About");
       public ActionResult SeeProduct()
           return View("Product");

I am sure that i didn't get the routing staff because when debugging I get "The view 'Home' or its master was not found. The following locations were searched"
I have modified the global.asax file like this

public static void RegisterRoutes(RouteCollection routes)
                 "Default", // Route name
                 "{controller}/{action}/{id}", // URL with parameters
                 new { controller = "Site", action = "GoTohome", id = UrlParameter.Optional } // Parameter defaults

Thank you for your help.
Posted 18-Feb-13 1:42am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

new { controller = "Site(controler name) ", action = "GoTohome(action name)", id = UrlParameter.Optional }
check this part ....

if home is view than action name must be home..

new { controller = "Site ", action = "home", id = UrlParameter.Optional }
simaodinho 18-Feb-13 9:47am
Yes Home is a view so I renamed the "Gotohome" action to "Home" as you said but i got the same error!!
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

I found the error,I have to add a folder named Site into the Views folder.However i didn't get why i should add this folder because Site is the name of the controller not the folder

any explanation

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.151126.1 | Last Updated 19 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100