1
我想从Attribute \ Filter构造函数中使用来自ControllerContext或ActionContext的信息。我怎么能这样做?试图将ControllerContext作为参数传递给操作中的属性,但没有成功。如何将ControllerContext传递给属性
我想从Attribute \ Filter构造函数中使用来自ControllerContext或ActionContext的信息。我怎么能这样做?试图将ControllerContext作为参数传递给操作中的属性,但没有成功。如何将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
}
过滤器实例'not'在每个请求的基础创建的上下文,所以你无法通过ControllerContext(这是每个请求特定的上下文中)到过滤器的构造。 –