Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have a SurfaceController that performs a Get method. When I attempt to access the current page using this.CurrentPage, I get the following error
Cannot find the Umbraco route definition in the route values, the request must be made in the context of an Umbraco request
Why is my controller not able to see the current page?
{ using System; using System.Threading.Tasks; using System.Web.Mvc; ... using Umbraco.Web.Mvc;
public class BenefitStatementPdfSurfaceController : SurfaceController { private readonly SelfServiceApiHttpClient _apiClient; public MySurfaceController(SelfServiceApiHttpClient apiClient) { _apiClient = apiClient; } [ActionName("MemberPdf")] [HttpGet] [Authorize] public async Task<ActionResult> MemberPdfAsync(int memberNumber, int selectedYear) { var content = await _apiClient .MemberPdfAsync(memberNumber, selectedYear) .ConfigureAwait(false); if (content.HasPdf) { return this.File(content.Pdf, "application/pdf", $"Statement{selectedYear}_{DateTime.Now:yyyyMMdd}_{DateTime.Now:HHmmss}.pdf"); } var nodeId = this.CurrentPage.Id; ------ERRORS HERE ... } }
}
Hi Mike
Try to use:
var nodeId = Umbraco.AssignedContentItem.Id;
Alex
What version of Umbraco are you using?
Did you solve this issue? Can you share with our community?
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
SurfaceController not able to access CurrentPage
I have a SurfaceController that performs a Get method. When I attempt to access the current page using this.CurrentPage, I get the following error
Why is my controller not able to see the current page?
{ using System; using System.Threading.Tasks; using System.Web.Mvc; ... using Umbraco.Web.Mvc;
}
Hi Mike
Try to use:
Alex
What version of Umbraco are you using?
Hi Mike
Did you solve this issue? Can you share with our community?
Alex
is working on a reply...