Hello, this is my 3rd day in a row trying various stuff from internet to accomplish something that would take 10 minutes in the old MVC approach.
I'm very confused on the multiple ways of using controllers (RenderController, SurfaceController, UmbracoPageController, ViewComponents).
In old MVC, I could have a Controller with multiple actions, [HttpGet], [HttpPost], prepare a view model and feed it to the view.
Right now, it's been a painful experience with Umbraco way of doing things
I'm forced to declare document types that match my controller names, otherwise it won't work with route hijackling
I must extend SurfaceController, or post requests won't work
I can't have even the simplest get method (other than Index), to display a view with an object
Keep getting this:
ModelBindingException: Cannot bind source type Orlando.BusinessObjects.Vehicle to model type Umbraco.Cms.Core.Models.PublishedContent.IPublishedContent
In order to use non-Index action, I have to create custom routes, and even then, I'll still get the same error as above
Is it really this bad to work with or I can't understand the basics of it?
How can I shift the MVC mindset I'm accustomed to, to the way Umbraco works?
For example, the view part
@using Umbraco.Cms.Web.Common.PublishedModels;
@using Orlando.BusinessObjects;
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
// If I comment this line below and try @model Vehicle, same problem
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Vehicle>
@{
Layout = "master.cshtml";
var vehicle = Model;
}
<div class="container-fluid p-0">
.....
</div>
Display simple view with a simple object
Hello, this is my 3rd day in a row trying various stuff from internet to accomplish something that would take 10 minutes in the old MVC approach.
I'm very confused on the multiple ways of using controllers (RenderController, SurfaceController, UmbracoPageController, ViewComponents).
In old MVC, I could have a Controller with multiple actions, [HttpGet], [HttpPost], prepare a view model and feed it to the view.
Right now, it's been a painful experience with Umbraco way of doing things
I can't have even the simplest get method (other than Index), to display a view with an object Keep getting this:
ModelBindingException: Cannot bind source type Orlando.BusinessObjects.Vehicle to model type Umbraco.Cms.Core.Models.PublishedContent.IPublishedContent
In order to use non-Index action, I have to create custom routes, and even then, I'll still get the same error as above
Is it really this bad to work with or I can't understand the basics of it? How can I shift the MVC mindset I'm accustomed to, to the way Umbraco works?
For example, the view part
Controller:
There is a good explanation of the different controllers here
https://www.jondjones.com/learn-umbraco-cms/umbraco-9-tutorials/getting-started-with-umbraco-9/ultimate-umbraco-v9-controller-guide/
is working on a reply...