开发者

RequestContext is empty at ProcessRequest() when using WCF REST Starter Kit

We have a very simple RequestInterceptor extension class for authentication with the following code:

public class AuthenticationInterceptor : RequestInte开发者_JAVA技巧rceptor
{
    public AuthenticationInterceptor() : base(false) { }
    public override void ProcessRequest(ref RequestContext requestContext)
    {
        // context is always null -- too early?
        return;
        if (HttpContext.Current != null)
        { ...
           }
    }

   ...
}public class SecureWebServiceHostFactory : WebServiceHostFactory
{
    protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
    {
        WebServiceHost2 host = new WebServiceHost2(serviceType, true, baseAddresses);
        host.Interceptors.Add(new AuthenticationInterceptor());
        return host;
    }
}

When we trigger a Ajax Request with Javascript, the requestContext is always null and the HttpContext.Current is null as well.

However, we were able to get the current context correctly at the .svc's constructor method.

Did we implement the interceptor incorrectly?

Thanks in advance. badallen

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜