我正在使用 asp.net mvc 4 rest 并编写自己的 basec 身份验证逻辑。
public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext actionContext)
{
if (actionContext.Request.Headers.Authorization == null)
{
actionContext.Response = new System.Net.Http.HttpResponseMessage(System.Net.HttpStatusCode.Unauthorized);
}
else
{
//do staff here
}
}
它适用于本地iis。但它不适用于生产站。我总是得到空值。我在 IIS 上设置了基本身份验证。我正在使用 Fiddler 进行测试,我的请求如下所示:
User-Agent: darwin/1.0 CFNetwork/548.1.4 Darwin/11.0.0
Authorization: Basic cmFkaWt2b3N0b2tAZ21haWwuY65tJjE6QkFBREVEcHlQYmtjQkFOcXh4UmFrdG1JMUJ2bjBPYXVQVk9NcnFZMEg4V3BhakljSlk2WkJMTWtra1FIWHFrcEZmdEkyNmFEZEppYWlKVVZJOTZpUGJuMzRMc1luemJHM2FPV3paQk5DTG1Xak9FZGU3YTdGWVhVem1QeTlEWkM4cW02YWZoWkJGWkIzbGFXMTNaQjlKdQ==
Content-Length: 10128
Accept: application/json
Content-Type: application/json
Connection: keep-alive
Host: 192.168.7.4
有人知道为什么会这样吗?