문제

My goal is to develop a Custom FilterAttribute, there i can apply to an action on ASP.NET Web API, where one of two thing should happens, but the resul must be the same:

Expected result: if some condition is verified, the action execution should be cancelled or redirected and a different object should be returned;

on a filterattribute to mvc i just have to change the actionname when im overriding a specific method.

does any one have ideas how to do the same on a webapi filterattribute?

SOLUTION:

if (true)
{
    IHttpRouteData x = request.Properties["MS_HttpRouteData"] as IHttpRouteData;
    x.Values["action"] = "IsUnavailableBecause";
}
도움이 되었습니까?

해결책

I'm not sure I understand what you are trying to do. Can you give an example?

Using message handlers would allow you to change the action route parameter before action selection has occurred.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top