diff --git a/src/Sagara.Core.AspNetCore/Extensions/PageModelExtensions.cs b/src/Sagara.Core.AspNetCore/Extensions/PageModelExtensions.cs
new file mode 100644
index 0000000..cd6bf12
--- /dev/null
+++ b/src/Sagara.Core.AspNetCore/Extensions/PageModelExtensions.cs
@@ -0,0 +1,26 @@
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.RazorPages;
+
+namespace Sagara.Core.AspNetCore.Extensions;
+
+public static class PageModelExtensions
+{
+ ///
+ /// Send a JsonResult whose object has a redirect property containing the URL that the client JavaScript should
+ /// redirect the browser to.
+ ///
+ /// The PageModel object.
+ /// The target page name.
+ /// The page handler, if any.
+ /// Route values, if any.
+ public static JsonResult RedirectToPageJson(this TPageModel pageModel, string pageName, string? pageHandler = null, object? values = null)
+ where TPageModel : PageModel
+ {
+ Check.NotNull(pageModel);
+
+ return new JsonResult(new
+ {
+ redirect = pageModel.Url.Page(pageName: pageName, pageHandler: pageHandler, values: values)
+ });
+ }
+}
diff --git a/src/Sagara.Core.AspNetCore/Filters/UnhandledExceptionFilter.cs b/src/Sagara.Core.AspNetCore/Filters/UnhandledExceptionFilter.cs
index aceeae7..dbfd727 100644
--- a/src/Sagara.Core.AspNetCore/Filters/UnhandledExceptionFilter.cs
+++ b/src/Sagara.Core.AspNetCore/Filters/UnhandledExceptionFilter.cs
@@ -70,7 +70,7 @@ public void OnException(ExceptionContext context)
log.AppendLine(CultureInfo.InvariantCulture, $" Raw URL: {context.HttpContext.Request.GetEncodedUrl()}");
}
- UnhandledExceptionFilterLogger.UnhandledException(_logger, context.Exception, log.ToString());
+ _logger.UnhandledException(context.Exception, log.ToString());
// Don't set it to handled. Let it continue through the pipeline.
}
@@ -82,5 +82,5 @@ public void OnException(ExceptionContext context)
internal static partial class UnhandledExceptionFilterLogger
{
[LoggerMessage(EventId = 0, Level = LogLevel.Error, Message = "{message}")]
- public static partial void UnhandledException(ILogger logger, Exception ex, string message);
+ public static partial void UnhandledException(this ILogger logger, Exception ex, string message);
}
diff --git a/src/Sagara.Core.AspNetCore/docs/Sagara.Core.AspNetCore.Extensions.PageModelExtensions.md b/src/Sagara.Core.AspNetCore/docs/Sagara.Core.AspNetCore.Extensions.PageModelExtensions.md
new file mode 100644
index 0000000..5288fe3
--- /dev/null
+++ b/src/Sagara.Core.AspNetCore/docs/Sagara.Core.AspNetCore.Extensions.PageModelExtensions.md
@@ -0,0 +1,56 @@
+#### [Sagara.Core.AspNetCore](index.md 'index')
+### [Sagara.Core.AspNetCore.Extensions](index.md#Sagara.Core.AspNetCore.Extensions 'Sagara.Core.AspNetCore.Extensions')
+
+## PageModelExtensions Class
+
+```csharp
+public static class PageModelExtensions
+```
+
+Inheritance [System.Object](https://docs.microsoft.com/en-us/dotnet/api/System.Object 'System.Object') 🡒 PageModelExtensions
+### Methods
+
+
+
+## PageModelExtensions.RedirectToPageJson(this TPageModel, string, string, object) Method
+
+Send a JsonResult whose object has a redirect property containing the URL that the client JavaScript should
+redirect the browser to.
+
+```csharp
+public static Microsoft.AspNetCore.Mvc.JsonResult RedirectToPageJson(this TPageModel pageModel, string pageName, string? pageHandler=null, object? values=null)
+ where TPageModel : Microsoft.AspNetCore.Mvc.RazorPages.PageModel;
+```
+#### Type parameters
+
+
+
+`TPageModel`
+#### Parameters
+
+
+
+`pageModel` [TPageModel](Sagara.Core.AspNetCore.Extensions.PageModelExtensions.md#Sagara.Core.AspNetCore.Extensions.PageModelExtensions.RedirectToPageJson_TPageModel_(thisTPageModel,string,string,object).TPageModel 'Sagara.Core.AspNetCore.Extensions.PageModelExtensions.RedirectToPageJson(this TPageModel, string, string, object).TPageModel')
+
+The PageModel object.
+
+
+
+`pageName` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String')
+
+The target page name.
+
+
+
+`pageHandler` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String')
+
+The page handler, if any.
+
+
+
+`values` [System.Object](https://docs.microsoft.com/en-us/dotnet/api/System.Object 'System.Object')
+
+Route values, if any.
+
+#### Returns
+[Microsoft.AspNetCore.Mvc.JsonResult](https://docs.microsoft.com/en-us/dotnet/api/Microsoft.AspNetCore.Mvc.JsonResult 'Microsoft.AspNetCore.Mvc.JsonResult')
\ No newline at end of file
diff --git a/src/Sagara.Core.AspNetCore/docs/index.md b/src/Sagara.Core.AspNetCore/docs/index.md
index d8dd883..03eb72c 100644
--- a/src/Sagara.Core.AspNetCore/docs/index.md
+++ b/src/Sagara.Core.AspNetCore/docs/index.md
@@ -3,6 +3,13 @@
## Sagara.Core.AspNetCore Assembly
### Namespaces
+
+
+## Sagara.Core.AspNetCore.Extensions Namespace
+- **[PageModelExtensions](Sagara.Core.AspNetCore.Extensions.PageModelExtensions.md 'Sagara.Core.AspNetCore.Extensions.PageModelExtensions')** `Class`
+ - **[RedirectToPageJson<TPageModel>(this TPageModel, string, string, object)](Sagara.Core.AspNetCore.Extensions.PageModelExtensions.md#Sagara.Core.AspNetCore.Extensions.PageModelExtensions.RedirectToPageJson_TPageModel_(thisTPageModel,string,string,object) 'Sagara.Core.AspNetCore.Extensions.PageModelExtensions.RedirectToPageJson(this TPageModel, string, string, object)')** `Method` Send a JsonResult whose object has a redirect property containing the URL that the client JavaScript should
+ redirect the browser to.
+
## Sagara.Core.AspNetCore.Filters Namespace