Hi, trying to add an MVC based section to the backoffice that will call an external API. Not sure if I'm setting this up correctly. I'm using Umbraco 12.
Then I tried creating a controller now to catch those requests. I put it in App_Plugins/Blogs but I'm still getting a 404 and struggling to know what to try next. Any ideas?
[Area("blogs")]
public class BlogsController : UmbracoAuthorizedController {
[HttpGet]
public IActionResult Index()
{
return Content($"Hello world - index");
}
[HttpGet]
public IActionResult Edit([FromRoute] int id)
{
return Content($"Hello world - blog {id}");
}
Perhaps supporting this conclusion is that when I visit
https://localhost:44365/umbraco/blogs I finally seem to be hitting my controller but I get no menu.
https://localhost:44365/umbraco#/blogs however gives me a section with the header. I am not an angular developer but apparently that pound sign is important.
I don't really want to spend $3000 per year to use the new UI Builder so I'll keep struggling on through an MVC solution.
In the edit.html file, you can then wrap an angular controller that use custom services to call your UmbracoAuthorizedController and return the data needed.
I ended up creating that view as you suggested, but putting an Iframe on it pointing to https://localhost:44365/umbraco/blogs, then created a controller there that could return an MVC view
[Area("blogs")]
[Authorize(Policy = AuthorizationPolicies.BackOfficeAccess, Roles = "admin,editor")]
public class BlogsController : Controller
{
[HttpGet]
public IActionResult Index()
{
var model = new BlogsModel();
model.Blogs.Add("President's Blog");
return View("~/App_Plugins/blogs/Views/Index.cshtml", model);
}
MVC Based Backoffice Section - Routing Newb
Hi, trying to add an MVC based section to the backoffice that will call an external API. Not sure if I'm setting this up correctly. I'm using Umbraco 12.
I added a section following instructions on https://docs.umbraco.com/umbraco-cms/extending/section-trees/sections
Now when I click on a tree node I end up at this url, which expectedly results in a 404. https://localhost:44365/umbraco#/blogs/blogeditor/edit/2
Then I tried creating a controller now to catch those requests. I put it in App_Plugins/Blogs but I'm still getting a 404 and struggling to know what to try next. Any ideas?
Then in my startup.cs file I tried the following:
Had to swap some less than and greater thans for square brackets in this forum post
Maybe what I'm trying to do is too much a mishmash of server and client. I just found this github issue that sounds exactly like what I'm describing.
https://github.com/umbraco/Umbraco-CMS/issues/8438
Perhaps supporting this conclusion is that when I visit https://localhost:44365/umbraco/blogs I finally seem to be hitting my controller but I get no menu.
https://localhost:44365/umbraco#/blogs however gives me a section with the header. I am not an angular developer but apparently that pound sign is important.
I don't really want to spend $3000 per year to use the new UI Builder so I'll keep struggling on through an MVC solution.
Like Sebastiaan write in the https://github.com/umbraco/Umbraco-CMS/issues/8438 there are no way around using an angular controller and a html view (as fare as he knows).
So when the url hit https://localhost:44365/umbraco#/blogs/blogeditor/edit/2 it is looking for a html file in
~/App_Plugins/{yourPluginName}/backoffice/{treeAlias}/edit.html
In the edit.html file, you can then wrap an angular controller that use custom services to call your UmbracoAuthorizedController and return the data needed.
Good luck.
Thanks, Bo.
I ended up creating that view as you suggested, but putting an Iframe on it pointing to https://localhost:44365/umbraco/blogs, then created a controller there that could return an MVC view
is working on a reply...