Skip to content

Commit e5acecd

Browse files
authored
Merge pull request #6574 from erikjanwestendorp/update-umbraco-context
Porting old Umbraco API Controller [Querying > Umbraco Context]
2 parents d06e032 + f8ac252 commit e5acecd

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

14/umbraco-cms/reference/querying/umbraco-context.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,21 @@ If you need an `UmbracoContext` in your own controllers, you need to inject an `
1818

1919
The following is an example of how to get access to the `UmbracoContext` in a controller:
2020

21-
{% hint style="warning" %}
22-
The example below uses UmbracoApiController which is obsolete in Umbraco 14 and will be removed in Umbraco 15.
23-
{% endhint %}
24-
2521
``` csharp
2622
using System;
2723
using System.Collections.Generic;
2824
using System.Diagnostics;
2925
using System.Linq;
3026
using Microsoft.AspNetCore.Mvc;
3127
using Umbraco.Cms.Core.Web;
32-
using Umbraco.Cms.Web.Common.Controllers;
3328
using Umbraco.Cms.Web.Common.PublishedModels;
3429
using Umbraco.Extensions;
3530

3631
namespace Umbraco.Docs.Samples.Web.Controllers.Api;
3732

38-
public class PeopleController : UmbracoApiController
33+
[ApiController]
34+
[Route("/umbraco/api/people")]
35+
public class PeopleController : Controller
3936
{
4037
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
4138

@@ -44,7 +41,7 @@ public class PeopleController : UmbracoApiController
4441
_umbracoContextAccessor = umbracoContextAccessor;
4542
}
4643

47-
[HttpGet]
44+
[HttpGet("getall")]
4845
public ActionResult<IEnumerable<string>> GetAll()
4946
{
5047
if (_umbracoContextAccessor.TryGetUmbracoContext(out IUmbracoContext? context) == false)

15/umbraco-cms/reference/querying/umbraco-context.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,21 @@ If you need an `UmbracoContext` in your own controllers, you need to inject an `
1818

1919
The following is an example of how to get access to the `UmbracoContext` in a controller:
2020

21-
{% hint style="warning" %}
22-
The example below uses UmbracoApiController which is obsolete in Umbraco 14 and will be removed in Umbraco 15.
23-
{% endhint %}
24-
2521
``` csharp
2622
using System;
2723
using System.Collections.Generic;
2824
using System.Diagnostics;
2925
using System.Linq;
3026
using Microsoft.AspNetCore.Mvc;
3127
using Umbraco.Cms.Core.Web;
32-
using Umbraco.Cms.Web.Common.Controllers;
3328
using Umbraco.Cms.Web.Common.PublishedModels;
3429
using Umbraco.Extensions;
3530

3631
namespace Umbraco.Docs.Samples.Web.Controllers.Api;
3732

38-
public class PeopleController : UmbracoApiController
33+
[ApiController]
34+
[Route("/umbraco/api/people")]
35+
public class PeopleController : Controller
3936
{
4037
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
4138

@@ -44,7 +41,7 @@ public class PeopleController : UmbracoApiController
4441
_umbracoContextAccessor = umbracoContextAccessor;
4542
}
4643

47-
[HttpGet]
44+
[HttpGet("getall")]
4845
public ActionResult<IEnumerable<string>> GetAll()
4946
{
5047
if (_umbracoContextAccessor.TryGetUmbracoContext(out IUmbracoContext? context) == false)

0 commit comments

Comments
 (0)