从WCF服务返回401 [英] Return 401 from WCF service

查看:170
本文介绍了从WCF服务返回401的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从WCF服务返回HTTP 401?

How can I return a HTTP 401 from a WCF service?

推荐答案

如果您正在编写REST服务,可以这样做:

If you are programming a REST-service it can be done this way:

private IWebOperationContext context = new WebOperationContextWrapper(WebOperationContext.Current); // Get the context

context.OutgoingResponse.StatusCode = HttpStatusCode.Unauthorized; // Set the 401

这篇关于从WCF服务返回401的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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