Skip to content

Commit

Permalink
修复提交留言时报错问题
Browse files Browse the repository at this point in the history
Fixs #504
  • Loading branch information
SeriaWei committed Dec 15, 2023
1 parent 48a945b commit af58b9d
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/ZKEACMS/Filter/RenderRefererPageAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
using Easy.Extend;
using System;
using System.Net;
using ZKEACMS.Route;
using System.Collections.Generic;
using System.Linq;

namespace ZKEACMS.Filter
{
Expand All @@ -21,14 +24,7 @@ private string GetPagePath(FilterContext filterContext)
{
return filterContext.HttpContext.Request.Form["CurrentPagePath"];
}
public override PageEntity GetPage(ActionExecutedContext filterContext)
{
string pagePath = GetPagePath(filterContext);
using (var pageService = filterContext.HttpContext.RequestServices.GetService<IPageService>())
{
return pageService.GetByPath(pagePath, false);
}
}

public override void OnActionExecuting(ActionExecutingContext filterContext)
{
string pagePath = GetPagePath(filterContext);
Expand Down Expand Up @@ -66,11 +62,16 @@ private void RedirectToRefererPage(ActionExecutedContext filterContext)

private void RenderRefererPage(ActionExecutedContext filterContext, ViewResult viewResult)
{
base.OnActionExecuted(filterContext);

var routeDataProviders = filterContext.HttpContext.RequestServices.GetServices<IRouteDataProvider>();
string pagePath = GetPagePath(filterContext);
foreach (var routeDataProvider in routeDataProviders.OrderBy(m => m.Order))
{
pagePath = routeDataProvider.ExtractVirtualPath(pagePath, filterContext.RouteData.Values);
}
filterContext.RouteData.Values["controller"] = "page";
filterContext.RouteData.Values["path"] = GetPagePath(filterContext);
filterContext.RouteData.Values["path"] = pagePath;
viewResult.ViewName = "PreView";
base.OnActionExecuted(filterContext);
}
}

Expand Down

0 comments on commit af58b9d

Please sign in to comment.