Created module but can't get to controller

Topics: General, Installing Orchard
Aug 19, 2014 at 12:32 PM
Hello there Orchard people

I have just created a new Orchard 1.8 module using this tutorial "http://docs.orchardproject.net/Documentation/Building-a-hello-world-module", I have added the routes.cs, a controller, a view, I also enabled the module but everytime I load up the project I get the standard page up first

Image

now when I try and go to "http://localhost:30322/home" I get the error message of "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: /home"

What have I done wrong? If you need more information please reply and let me know.
Aug 19, 2014 at 12:45 PM
Edited Aug 19, 2014 at 12:50 PM
Please provide some more information. Does the log say anything? (YourOrchardProject -> src -> Orchard.Web -> App_Data -> Logs)

Is the module enabled correctly? Is the route correct (specifically the Area)?
Aug 19, 2014 at 12:58 PM
Here is a image of the module enabled

Image

Looking at the logs I am getting nothing out of them

Here is my Routes.cs
using Orchard.Mvc.Routes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace Projects.Web
{
    public class Routes : IRouteProvider
    {
        public void GetRoutes(ICollection<RouteDescriptor> routes)
        {
            foreach (var routeDescriptor in GetRoutes())
                routes.Add(routeDescriptor);
        }

        public IEnumerable<RouteDescriptor> GetRoutes()
        {
            return new[] {
                new RouteDescriptor {
                    Priority = 5,
                    Route = new Route(
                        "Projects.Web",
                        new RouteValueDictionary {
                            {"area", "Projects.Web"},
                            {"controller", "Home"},
                            {"action", "Index"}
                        },
                        new RouteValueDictionary(),
                        new RouteValueDictionary {
                            {"area", "Projects.Web"}
                        },
                        new MvcRouteHandler())
                }
            };
        }
    }
}
So not sure why I can't access my home controller
Aug 19, 2014 at 1:07 PM
It's ok I got it working

All I had to do was change the RouteDescriptor area like so
Route = new Route(
                        "Home/{action}",
                        new RouteValueDictionary {
However when I first load my project and it goes to http://localhost:30322/ it still has the standard orchard page there, how do I remove this and show my new home index page?
Aug 19, 2014 at 1:08 PM
Edited Aug 19, 2014 at 1:11 PM
Edit: you already found the solution while I was typing that.

Use the 'Alias' module to use your own homepage.
Aug 19, 2014 at 1:26 PM
Alias is enabled, how do I use it?
Aug 19, 2014 at 2:41 PM
Enable Alias UI module too, then set up a new Alias with route "/" to your module's controller link ("/Home" in your case)
Aug 19, 2014 at 3:34 PM
That works fine cheers Sanderg,

Just a quick question, I want to edit the Layout of the page so it will load up some standard javascript files, how would I do this? In the project I created a new folder in themes called ProjectThemes and create a folder called Views and I created a new Layout.cshtml page and just give it a H2 tag, I then went into my Home/Index view and set the Layout to be the new ProjectThemes\View\Layout.cshtml but it informs me saying the orchard layout is read only, why is that?
Developer
Aug 19, 2014 at 7:01 PM
Orchard configures the base class of views to be Orchard.Mvc.ViewEngines.Razor.WebViewPage, which exposes a Layout property that has nothing to do with the Layout property you can set in a regular MVC application. In Orchard, Layout is a shape, so you can create a Razor file in the root of the Views folder of your theme and render your h2 element. Also render the Content zone, like this: @Display(Model.Content).
Aug 21, 2014 at 10:50 AM
Edited Aug 21, 2014 at 11:25 AM
Ok sfmskywalker so at the moment I have a view in my Views\Home which is the index so at the moment the view looks like this
@using Boxharry.Extensions;

<h2>Page</h2>
I have created myself a Document.cshtml in my Themes\Web\Views\Document.cshtml here is the code for that
<!DOCTYPE html> 
<html lang="@WorkContext.CurrentCulture" class="static @Html.ClassForPage()"> 
<head> 
    <meta charset="utf-8" />
    <title>@Html.Title("Recruit Agent Web", "Web")</title>
    @Display(Model.Head)
</head> 
<body>
    <h2>THE TITLE</h2>
@Display(Model.Content)
</body>
</html>
But this content still doesn't render in my Index view,

UPDATE

I have just gone thought and created myself a new theme
codegen theme web
I logged into the admin are and set the new theme, I created a document view and layout view and I still can't get them to render any part of their view, the home view just renders with nothing extra
Aug 21, 2014 at 11:51 AM
Have you added the [Themed] attribute to your controller or action?
Aug 21, 2014 at 12:35 PM
I have now and it works fine, Thank you again guys