Surface controller actions
Information about Surface Controller Actions Result Helpers in Umbraco
A surface controller can return a few Umbraco specific actions.
CurrentUmbracoPage
Returns the current Umbraco page.
namespace RoutingDocs.Controllers;
public class MyController : SurfaceController
{
public MyController(
IUmbracoContextAccessor umbracoContextAccessor,
IUmbracoDatabaseFactory databaseFactory,
ServiceContext services,
AppCaches appCaches,
IProfilingLogger profilingLogger,
IPublishedUrlProvider publishedUrlProvider)
: base(umbracoContextAccessor, databaseFactory, services, appCaches, profilingLogger, publishedUrlProvider)
{
}
[HttpPost]
public IActionResult PostMethod()
{
if (!ModelState.IsValid)
{
return CurrentUmbracoPage();
}
return RedirectToCurrentUmbracoPage();
}
}RedirectToCurrentUmbracoPage
Redirects to the currently rendered Umbraco page.
This action can also take in a QueryString object to be included in the redirect.
Querystring parameter using a string value
RedirectToCurrentUmbracoUrl
Redirects to the currently rendered Umbraco URL.
RedirectToUmbracoPage
Redirects to a given Umbraco page.
You can also redirect to a page key (GUID).
There are overloads for adding a QueryString object.
Last updated
Was this helpful?