我想从Attribute \ filter构造函数内部使用来自ControllerContext或ActionContext的信息。我该怎么做?尝试将ControllerContext作为来自动作的属性的参数,但没有成功。

有帮助吗?

解决方案

public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
           var controllerContext =  filterContext.Controller.ControllerContext;
.

执行执行。你不能在施工中有上下文

其他提示

   [HttpGet]
    public ActionResult VideoStream(int id = 0)
    {
     }
    public override void ExecuteResult(ControllerContext context)
    {
        string routedata = context.RequestContext.RouteData.Values["id"].ToString();
        //The File Path 
        var videoFilePath = HostingEnvironment.MapPath("~/CombineFile/Tanvir.mp4");
        //The header information 

    } 
.
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top