0
WCF REST 스타터 키트의 RequestInterceptor에 대한 기술적 인 정보를 찾고 있었지만 원하는 내용을 찾지 못했습니다. 코드 조각 사용자 지정 서비스 호스트 공장에서했다에서의이 보자 :WCF REST StarterKit 및 RequestInterceptor 스레드 안전성
protected override System.ServiceModel.ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
var host = (WebServiceHost2)base.CreateServiceHost(serviceType, baseAddresses);
var authenticationProvider = Container.TryGetInstance<IAuthenticationProvider>();
var authorizationRepository = Container.TryGetInstance<IUserFinder>();
if (authenticationProvider == null)
authenticationProvider = new DefaultAuthenticationProvider(authorizationRepository);
var securityContext = new SecurityContext();
host.Interceptors.Add(new AuthenticationInterceptor(authenticationProvider, securityContext));
return host;
}
그 코드 inCreateServiceHost 방법은 한 번만 실행됩니다.
그러나 모든 HTTP 요청에서 AuthenticationInterceptor가 실행됩니다. AuthenticationInterceptor는 SecurityContext 클래스와 IUserFinder 저장소에 종속되어 있음을 알 수 있습니다.
여러 HTTP 요청이 동시에 발생하면 어떻게됩니까?
- WCF는 AuthenticationInterceptor를 동시에 실행하므로 SecurityContext 및 IUserFinder 인스턴스가 스레드로부터 안전해야합니까? IUserFinder는 데이터베이스 리소스에 의존합니다.
- 각 요청은 하나씩 차례로 실행되므로 AuthenticationInterceptor를 두 번의 서로 다른 호출에서 동시에 실행할 수 없습니까?