【问题标题】:Authentication cookie ignored by REST proxy requestsREST 代理请求忽略的身份验证 cookie
【发布时间】:2013-04-02 03:18:45
【问题描述】:

同一域上的 3 台服务器。具有表单身份验证的自定义成员资格提供程序。

  1. 带有登录名的 ASP.net 网络表单(表单身份验证)
  2. ASP.net webapi
  3. ExtJs 网络应用程序

1 和 2 之间的身份验证工作正常。 Auth cookie 正在按预期在浏览器中设置。直接从浏览器使用 webapi 方法可以。

问题:服务器 #3 中的 ExtJs REST 代理未发送授权 cookie。服务器以 401 Unauthorized 响应所有 OPTIONS 和 GET。

我真的很感激任何帮助。 谢谢。

请求标头:

GET /api/codigos/?aux=xtiposoli&_dc=1364785770273&page=1&start=0&limit=25&filter=%5B%7B%22property%22%3A%22nombre%22%7D%5D HTTP/1.1
Host: webapi.pruebas.com:8888
Connection: keep-alive
Origin: http://users.pruebas.com:8889
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22
Accept: */*
Referer: http://users.pruebas.com:8889/app.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: es-ES,es;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

响应标头:

HTTP/1.1 401 Unauthorized
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcVG9ueU1heW9yYWxcRHJvcGJveFxQcm95ZWN0b3NcTmV0MjAxMlxTRVNcU0VTLldlYkFwaVxhcGlcY29kaWdvc1w=?=
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Date: Mon, 01 Apr 2013 03:09:35 GMT
Content-Length: 71

【问题讨论】:

    标签: extjs extjs4 asp.net-web-api membership-provider


    【解决方案1】:

    我设法通过以下更改解决了这个问题:

    ExtJs 应用启动:

    Ext.Ajax.useDefaultXhrHeader = false;
    Ext.Ajax.withCredentials=true;
    

    WebApi 的 web.config:

      <add name="Access-Control-Allow-Credentials" value="true" />
      <add name="Access-Control-Allow-Origin" value="http://users.pruebas.com:8889" />
      <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
      <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
    

    【讨论】:

      猜你喜欢
      • 2011-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-21
      • 1970-01-01
      • 2014-10-02
      • 2016-08-15
      相关资源
      最近更新 更多