如何覆盖WCF以返回状态码401(未授权) [英] How Can I Override WCF To Return Status Code 401 (Not authorized)

查看:124
本文介绍了如何覆盖WCF以返回状态码401(未授权)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何拦截对我的数据服务(* .svc文件)的调用以注入我自己的逻辑,该逻辑将检查用户当前是否在其asp.net会话中进行身份验证仍处于活动状态?  当我检测到这种情况时,计划返回一个401代码,以便
我的ajax库做出适当的反应。


我知道如何查询会话并设置适当的标题但是我不知道如何挂钩到WCF数据服务处理管道。


谢谢


标记

解决方案

我希望以下文章可以提供帮助:  http://blogs.msdn.com/b/astoriateam/archive/2010/07/19/odata-and-authentication-part-4-server-侧hooks.aspx

How can I intercept a call to my data service (*.svc file) to inject my own logic that would check to see if the user is currently authenticated in their asp.net session is still active?  When I detect this situation plan to return a 401 code so that my ajax library reacts appropriately.

I know how to interrogate the session and set the appropriate headers but I don't know how to hook into the WCF Data Services processing pipeline.

Thanks

Mark

解决方案

I hope the following article should help: http://blogs.msdn.com/b/astoriateam/archive/2010/07/19/odata-and-authentication-part-4-server-side-hooks.aspx


这篇关于如何覆盖WCF以返回状态码401(未授权)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆