2014-11-05 4 views

답변

1

WebAPI에서는 filters을 사용할 수 있습니다. OnActionExecutingOnActionExecuted을 무시할 수 있습니다. 당신은 모든 단일 컨트롤러에 주석을 원하지 않는 경우, 당신은 당신의 필터 루게릭 병 글로벌 필터를 추가 할 수 있습니다

GlobalConfiguration.Configuration.Filters.Add(new MyFilterAttribute()); 

을 대체 ApplicationStart에 대한 당신의 OwinStartup 클래스에서 코드를 실행할 수 있습니다. ApplicationEnd과 비슷한 것이 있는지 나는 모른다.

4

파이프 라인 시작 부분에 간단한 시작 미들웨어를 추가하여 시작 및 종료 요청을 처리합니다.

public class SimpleMiddleWare:OwinMiddleware 
{ 
    public SimpleMiddleWare(OwinMiddleware next) : base(next) 
    { 
    } 

    public override async Task Invoke(IOwinContext context) 
    { 
     Debug.WriteLine("Begin Request");//Add begin request logic 
     await Next.Invoke(context); 
     Debug.WriteLine("End Request");//Add end request logic 
    } 
} 
관련 문제