http - 从 WCF 服务返回 401

标签 http wcf http-status-code-401

如何从 WCF 服务返回 HTTP 401?

最佳答案

如果您正在编写 REST 服务,则可以通过以下方式完成:

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

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

关于http - 从 WCF 服务返回 401,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1968300/

相关文章:

php - 收到数据后关闭 HTTP 连接

.net - 从 Silverlight 调用 WCF 服务 : Somewhere my parameters are disappearing

php - 在 php 中将 float 组作为 HTTP POST 请求发送

java - Android HttpEntry 读取在 Droid x 上挂起

asp.net - 在被 WCF 类解析之前,如何在 IIS 中即时修改不正确的 XML header (编码)?

http - 在 axios 中设置授权 header

python - 使用带有 graphql 查询的 API 在 R 上抛出 401 错误,但在 Python 上工作正常

ios7 - IOSLinkedInAPI : Can't share post with the LinkedIn API

java - 谁能解释这个异常

c# - 如何在 C# 中将 IList<T> 转换为 List<T>,性能良好且简洁?