【发布时间】:2017-01-19 16:55:14
【问题描述】:
我需要通过 http 方法和路由模板来限制对控制器方法的访问。如何从 context var 中获取路由模板?
public abstract class BaseController : Controller
{
public override void OnActionExecuting(ActionExecutingContext context)
{
string apiKey = context.HttpContext.Request.Headers["key"];
string httpMethod = context.HttpContext.Request.Method.ToUpper();
string routeTemplate = context. ???
if (CheckAccess(apiKey, httpMethod , routeTemplate))
{
context.Result = Forbid();
}
}
}
【问题讨论】:
标签: c# asp.net-web-api asp.net-core asp.net-core-webapi