Closed ibiza240 closed 4 years ago
@ibiza240 It seems recipe that you used to setup doesn't have default home page. Access /admin
and create content item that you want to set it as home page.
Thanks for your reply @ns8482e!
The recipe I picked is Blank and you are right that I have no content items but I don't think this is the problem - I don't want a content item as the home page, rather a custom MVC view (I am testing with the "Hello World" sample module).
Here is the Startup.cs
from the OrchardCore.Mvc.HelloWorld
project (the sample module):
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Configuration;
using OrchardCore.Modules;
namespace OrchardCore.Mvc.HelloWorld
{
public class Startup : StartupBase
{
private readonly IConfiguration _configuration;
public Startup(IConfiguration configuration)
{
_configuration = configuration;
}
public override void Configure(IApplicationBuilder builder, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)
{
if (string.IsNullOrEmpty(_configuration["Sample"]))
{
throw new Exception(":(");
}
routes.MapAreaControllerRoute
(
name: "Home",
areaName: "OrchardCore.Mvc.HelloWorld",
pattern: "",
defaults: new { controller = "Home", action = "Index" }
);
}
}
}
I did not change it at all, and it was working great before activating CMS. Basically it re-routes the home page (root url) to the Home controller in the sample module, so that "Hello World" is displayed directly from the root url.
I would expect this to still be working after activating the CMS on the website project. That's what is confirming that MVC is working well, which is not for me after activating the CMS...in fact if I put a breakpoint in that Configure
function, it's not hit anymore on startup, after activating the CMS.
If you picked up the blank recipe then there is no homepage set. This is intentional as some people are using Orchard Core as a API server for their headless websites. This means that the only thing they require from Orchard Core is to have a /admin (or now you can set this to / as the admin url is now configurable). So it is working as it should and as expected. If you want a home page. You can still create one but you will need to configure it in your OC database because Orchard Core has a default route for the homepage which is configurable in the SiteSettings in the Document table.
some people are using Orchard Core as a API server for their headless websites. This means that the only thing they require from Orchard Core is to have a /admin
This is called "Decoupled CMS", right? That is exactly what I want to achieve...
The gist of my problem is not that the home page is not set, but rather that the Hello World
module is not recognized anymore after I activated the CMS in the Startup class of the website...
Anyone can help me identify what is incorrect in my setup?
Are you using source code or Nuget package solution? Because if you are using source code you need to add your module reference to the https://github.com/OrchardCMS/OrchardCore/blob/dev/src/OrchardCore/OrchardCore.Application.Cms.Targets/OrchardCore.Application.Cms.Targets.csproj Else you add the reference to your website project.
I am using Nuget package and the module is referenced from the website project
Does it have a manifest.cs file?
The module has the Manifest file from the sample project, I did not modify it:
using OrchardCore.Modules.Manifest;
[assembly: Module(
Name = "Mvc HelloWorld"
)]
Is that module enabled in the features?
/Admin/Features
A priori, I would say you probably found the problem since I did not enable the module in the Admin backend.
But now I can't login into the Admin, when I login I get back to the login page infinitely.
I will try to solve that problem now, and report back here :)
This can be a cookie issue. Just delete all your cookies and retry. I get this issue often.
Thanks @Skrypt, activating the module in the CMS is what I was missing!
@ibiza240 I had the same problem as yours and @Skrypt answer saves us. thanks
Hi!
I am trying really hard to make this work as the framework looks promising. Ultimately, I want to be able to use the CMS backend for managing content and writing my own MVC views and controllers for displaying it.
I am using the Sample projects provided in the solution:
This is showcasing an MVC webapp using Orchard Core, hence I need to add the CMS part to it for what I need.
Here's the original
Startup.cs
from theOrchardCore.Mvc.Web
project, the webapp works perfectly when launching it:So all that is missing is the CMS, right? Here's what I tried:
OrchardCore.Application.Cms.Targets
nuget package reference to theOrchardCore.Mvc.Web
project.AddOrchardCms()
to the IServiceCollection in ConfigureServices aboveThen I run the webapp again and am greeted with the Setup page for the CMS. Cool! I complete the setup and then, when it goes back to the home page, I now get a page displaying the "The page could not be found." message...
So it seems it is not recognizing anymore the Hello world module :(
What am I missing? Thanks!