src/ZKEACMS/Extend/ActionContextExtend.cs
(完整代码) 1KB/* http://www.zkea.net/
* Copyright (c) ZKEASOFT. All rights reserved.
* http://www.zkea.net/licenses */
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System;
using System.Collections.Generic;
using System.Text;
namespace ZKEACMS
{
public static class ActionContextExtend
{
public static void NotFoundResult(this ActionContext actionContext)
{
var executedContext = actionContext as ActionExecutedContext;
if (executedContext != null && executedContext.Result is ViewResult)
{
var viewResult = executedContext.Result as ViewResult;
viewResult.StatusCode = 404;
viewResult.ViewName = "NotFound";
}
}
public static void RedirectTo(this ActionContext actionContext, string url, bool permanent = false)
{
var executedContext = actionContext as ActionExecutedContext;
if (executedContext != null && executedContext.Result is ViewResult)
{
executedContext.Result = new RedirectResult(url, permanent);
}
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。