Open MarGraz opened 9 months ago
I noticed that there is a discrepancy in the official documentation. The second GIF image recommends using the NuGet packages OrchardCore.Application.Cms.Targets
and OrchardCore.Application.Targets
. However, another section of the documentation here advises using OrchardCore.Application.Cms.Targets
and OrchardCore.Application.Cms.Core.Targets.
After updating my WebApp to reference OrchardCore.Application.Cms.Targets
and OrchardCore.Application.Cms.Core.Targets
, both version 1.8.2, I still encounter the same error, with or without my theme project referenced or not.
The issue starts with creating a new blank "ASP.NET Core Web Application" in VS 2022 using the manual method. This process, unlike the automated template, results in Visual Studio automatically adding Controllers
and Views
folders with files, that subsequently cause errors in Orchard Core, specifically because of the Error.cshtml
view model. Excluding the Controllers
and Views
folders from the project fix this issue.
I noticed that the official documentation does not mention to remove Controllers
and Views
folders when starting a project with the manual method, right? 🤔
Controllers
, Views
and Models
folders from the Web App, assuming this is the correct approach 😊@MarGraz
is there a controller in your web project that handle errors? You may have Error.cshtml
in the shared folder which should be removed. Also, if you have a controller in your webapp that handles errors, delete it
@MikeAlhayek yes, thank you. I solved as I explained here. What do you think about the two questions I asked?
@MarGraz sorry I did not see you follow up comments. Glad you fixed the issues.
Yes feel free to submit a PR to modify the documentation to mention removing the views and controller if existing.
@MikeAlhayek ok, I have just two questions:
Thank you
Regarding https://github.com/OrchardCMS/OrchardCore/issues/15267#issuecomment-1932152014 I posted, which library is the correct one to be used?
OrchardCore.Application.Cms.Core.Targets
orOrchardCore.Application.Cms.Targets
can be used. It depends on the scenario you want to achieve. I would suggest to useOrchardCore.Application.Cms.Targets
and change it if neededWhere in the documentation is the "manual method" mentioned? Is it only on this page?
In this section https://docs.orchardcore.net/en/main/docs/getting-started/templates/#from-visual-studio-manual-way we should add a section to mention removing the views and controllers.
Describe the bug
I followed the official documentation to create a new Orchard Core Web App and installed the
OrchardCore.Application.Cms.Targets
andOrchardCore.Application.Targets
NuGet packages as suggested in the second GIF image. After configuring the Web App to use a SQL Server on localhost and starting the app, I encountered an error on the front end:An unhandled exception occurred while processing the request. InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'OrchardCore.Diagnostics.ViewModels.HttpErrorShapeViewModel', but this ViewDataDictionary instance requires a model item of type 'WebApp.Models.ErrorViewModel'. Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.EnsureCompatible(object value)
Despite using a blank recipe, which I thought might naturally lead to front-end errors, I followed the official guide to create my own theme (using the Code Generation Templates) and added a Layout.cshtml with only an "Hello world" text. I also updated the .csproj file to use the
Microsoft.NET.Sdk.Razor
SDK, but the error persisted.To Reproduce
Steps to reproduce the behavior:
ASP.NET Core Web Application
(.NET 8) in VS 2022 v. 17.8.6;OrchardCore.Application.Cms.Targets
v. 1.8.2 andOrchardCore.Application.Targets
v. 1.8.2 from the stable NuGet feed, as shown in the second GIF image;CTRL
+F5
and configure it to use a localhost SQL Server;Expected behavior
Using a "Blank Recipe" I expected not to see a template, but also not to encounter an exception. Ideally, a simple text page should appear, guiding the user to consult the documentation for creating a custom theme and locating the "Admin" panel.
Endpoint
Route Values
Exception details
Screenshots