[RESOLVED] Error: "The view 'Index' or its master was not found or no view engine supports ..."
Hello, I've been following a tutorial in developing an MVC shopping cart but I get the following error when i try to access the controller class:
The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/ShoppingCart/Index.aspx
~/Views/ShoppingCart/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/ShoppingCart/Index.cshtml
~/Views/ShoppingCart/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
The url looks ok but it's not picking up the right file I think: http://localhost:1565/ShoppingCart/Index
The tutorial is found here: http://www.asp.net/mvc/tutorials/mvc...c-store-part-8
Please will someone advice.
Thanks,
Garry
Re: Error: "The view 'Index' or its master was not found or no view engine supports .
Ok, I've added the view to the shared folder of the Views folder and the view works now but why won't it world from the top level folder?
Re: Error: "The view 'Index' or its master was not found or no view engine supports .
Quote:
~/Views/ShoppingCart/Index.aspx
~/Views/ShoppingCart/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/ShoppingCart/Index.cshtml
~/Views/ShoppingCart/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
It should be at one of the paths I've highlighted. Was it?
Re: Error: "The view 'Index' or its master was not found or no view engine supports .
Quote:
Originally Posted by
jmcilhinney
It should be at one of the paths I've highlighted. Was it?
I'm not sure what you mean. I placed the view in the Views>Shared folder and it worked but if i place in the Views folder I get the error. This is the URL I use: http://localhost:1565/ShoppingCart/Index or http://localhost:1565/ShoppingCart/Index.
Re: Error: "The view 'Index' or its master was not found or no view engine supports .
The error message tells you which file paths were searched for the view. Are any of those paths in the Views folder? No they are not, so obviously your view should not be in the views folder. Look at the ones I've highlighted. Those are the only ones reasonable for your view. Are any of them in the Shared folder? No they are not, so obviously your view should not be in the Shared folder. It's not shared is it? It's only used by one controller isn't it? It should be in the folder that corresponds to that controller, as I have demonstrated by highlighting the valid paths.
Re: Error: "The view 'Index' or its master was not found or no view engine supports .
Thanks mate! This makes a more sense now I've added the ShoppingCart directory in the views folder.
Re: [RESOLVED] Error: "The view 'Index' or its master was not found or no view engine
I haven't looked at the tutorial you were using but you should be simply right-clicking on the action name and selecting Add View and it will create it in the right place for you.