This project is read-only.

Orchard Can't Find Module View?

Oct 18, 2010 at 6:18 AM

I've finally gotten some time to start working on a contact module for Orchard, and I've been going through slowly to verify that I understand what I'm doing.  At this point, I have a module with no database parts at all, simple a main and admin menu item, as well as an admin view that shows a few useless input fields.  I got through inserting the menu items without problem, but now that I'm trying to show the admin view I've run into a difficulty.  The error message I receive is here:

The view 'index' or its master was not found. The following locations were searched:

My admin menu item is built with the following code:

using Orchard.Localization;
using Orchard.Security;
using Orchard.UI.Navigation;

namespace SimpleContactForm {
	public class AdminMenu : INavigationProvider {
		public Localizer T { get; set; }
		public string MenuName { get { return "admin"; } }

		public void GetNavigation(NavigationBuilder builder) {
			builder.Add(T("Content"), "2", menu => menu.Add(T("Simple Contact"), "1.5", item => item.Action("Index", "Admin", new { area = "SimpleContactForm" }).Permission(StandardPermissions.AccessAdminPanel)));
I have been following various different tutorials on the main OrchardProject website, I'd assume I'm just missing something here.  Any help is appreciated.

Oct 18, 2010 at 7:01 AM
Edited Oct 18, 2010 at 7:04 AM

The action's default view called Index.* could not be found.

Do you have a controller called admincontroller with an action called Index?

I have not done much Orchard yet but I recall that the routing is not defined in the global.aspx.cs file like most MVC code in .NET so it could also be a routing error.

Either something with routing  or you really have not created a view with a corresponding controller such as AdminController.



Oct 18, 2010 at 7:08 AM

I should have added that I did have a controller and view setup.

~/Modules/SimpleContactForm/Controllers/AdminController.cs - Contains an ActionResult Index() method

Oct 18, 2010 at 7:26 AM
Edited Oct 18, 2010 at 7:28 AM

Since you are referencing the partial view from a folder other than the default folder(s), you will need to reference the full virtual path.

Are you referencing the full path like this?   <%: Html.Partial("~/Modules/SimpleContactForm/Views/Admin/Index.ascx")%>

The default path for your partial view is :

or if using an Area



Now I'm not sure what changes Orchard has that may affect this default setting.

Oct 18, 2010 at 7:32 AM

I've been mixing and matching some of the tutorials on OrchardProject's website, and if I've read them correctly they all instruct you to create a partial view.  I imagine this has to do with the theme engine, but there's way too much abstraction in here for me to care enough to learn.

Oct 18, 2010 at 7:45 AM

Make sure that you have marked your controller with [Themed] attribute.




Oct 18, 2010 at 3:25 PM

Thank you Ajay, I knew it was going to be something stupid I was forgetting.