1
如何訪問ActionExecutingContext
中的Request.Properties
?如何訪問ActionExecutingContext中的Request.Properties
public class UserFilter : ActionFilterAttribute
{
public void OnActionExecuting(ActionExecutingContext actionContext)
{
// Properties is not part of the Request here, so I can't access it
// Here Request is of type System.Web.HttpRequestBase
actionContext.HttpContext.Request.Properties.Add("UserData", new UserData());
}
}
我能做到這一點在ApiController
:
public class HomeController : ApiController
{
public HomeController()
{
// Here I can do it (here Request is of type
// System.Net.Http.HttpRequestMessage
this.Request.Properties.Add("UserData", new UserData());
}
}