在标准的.Net Web中使用普罗米修斯mapPath上的ActionFilter,可以通过以下步骤实现:
public class PrometheusActionFilter : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
// 在Action执行之前的逻辑处理
string path = filterContext.HttpContext.Server.MapPath("~/");
// 其他逻辑处理
}
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
// 在Action执行之后的逻辑处理
string path = filterContext.HttpContext.Server.MapPath("~/");
// 其他逻辑处理
}
}
[PrometheusActionFilter]
public class YourController : Controller
{
// Action方法
}
<system.web>
<httpModules>
<add name="PrometheusActionFilter" type="YourNamespace.PrometheusActionFilter, YourAssembly" />
</httpModules>
</system.web>
protected void Application_Start()
{
// 其他初始化代码
GlobalFilters.Filters.Add(new PrometheusActionFilter());
}
通过以上步骤,就可以在标准的.Net Web中使用普罗米修斯mapPath上的ActionFilter了。在ActionFilter中,可以通过filterContext.HttpContext.Server.MapPath方法获取当前应用程序的物理路径,进行相应的处理。
云+社区开发者大会 长沙站
腾讯云培训认证中心开放日
云+社区技术沙龙 [第31期]
DBTalk技术分享会
腾讯技术开放日
云+社区技术沙龙[第8期]
云原生正发声
北极星训练营
领取专属 10元无门槛券
手把手带您无忧上云