asp.net-web-api - 允许在 web api 中自定义标题

标签 asp.net-web-api http-headers

我需要允许一个名为“secretToken”的自定义 header 。每次调用我的 webapi 时,用户都应该传递这个 header 。

我寻找了一种方法来做到这一点,但我找不到一种简单的方法。我怎样才能允许这个自定义标题?

最佳答案

.config 文件中还有一件事:

    <httpProtocol>
        <customHeaders>
            <add name="Access-Control-Allow-Origin" value="*" />
            <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept,auth-key" />
        </customHeaders>
    </httpProtocol>

关于asp.net-web-api - 允许在 web api 中自定义标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17684870/

相关文章:

apache - 在 Apache2 访问日志中记录 HTTP header

http - 可以执行 "relative"使 HTTP header 过期吗?

c# - Web API 自定义验证以根据批准的值列表检查字符串

JQuery AJAX方法在JSONP请求上调用 "error"函数而不是 "success"函数

C# ASP.NET MVC 4 Web API XmlDocumentationProvider 错误

c++ - cURL 请求已更改

if-statement - 仅当 cookie 存在时,如何有条件地覆盖 nginx 中的 header ?

asp.net-mvc - 从 ASP.NET Web API 返回一些字段

asp.net-web-api - 验证用户名和密码而不验证用户身份

java - Resteasy Content-Type 默认值