我已经实现了 IdispatchMessageInspector 的成员来验证SOAP标头中的tokenId。如果令牌无效,我想重定向并显示错误消息。因此它将限制访问Web方法。我不知道怎么办?有人这样做过吗?
#region IDispatchMessageInspector会员
public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, IClientChannel channel, InstanceContext instanceContext)
{
if !(ValidateToken(tokenValue))
//Redirect the error message
return null;
}
public void BeforeSendReply(ref System.ServiceModel.Channels.Message reply, object correlationState)
{
//Log the Response with Log4Net or
Console.WriteLine("IDispatchMessageInspector.BeforeSendReply called.");
}
#endregion