“Flash方法不允许”仅在Firefox 6中,但在调用WCF服务时不在IE 9中

时间:2021-09-16 19:35:40

I have a WCF service hosted on http://localhost:8080, and a web application on http://localhost:82. I have Windows 7 64-bit and IIS 7.5.

我有一个托管在http:// localhost:8080上的WCF服务,以及一个位于http:// localhost:82上的Web应用程序。我有Windows 7 64位和IIS 7.5。

The pages in the web app makes AJAX requests to the WCF service using jQuery.

Web应用程序中的页面使用jQuery向WCF服务发出AJAX请求。

In IE, the service calls perform fine. In Firefox, I get a 405 Method Not Allowed error. The service calls that the web application makes from the ASP.NET code-behind always succeed.

在IE中,服务调用执行正常。在Firefox中,我得到405 Method Not Allowed错误。 Web应用程序从ASP.NET代码隐藏中调用的服务始终成功。

Other developer's builds are having the same problem. I initially thought it had to do with cross-site security restrictions that were introduced in FF 3.5, based on this article: https://developer.mozilla.org/En/HTTP_access_control. However, after adding all the response headers I appeared to need, the problem still occurred.

其他开发人员的版本也存在同样的问题。我最初认为它与FF 3.5中引入的跨站点安全限制有关,基于这篇文章:https://developer.mozilla.org/En/HTTP_access_control。但是,在添加了我认为需要的所有响应头之后,问题仍然存在。

I've run the aspnet_regiis.exe command, and the WCF ServiceModelReg.exe command as well.

我也运行了aspnet_regiis.exe命令和WCF ServiceModelReg.exe命令。

Here is the request that Firefox makes:

这是Firefox制作的请求:

OPTIONS http://localhost:8080/ScoutService.svc/Contact_Add HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: keep-alive
Origin: http://localhost:82
Access-Control-Request-Method: POST
Access-Control-Request-Headers: content-type
Pragma: no-cache
Cache-Control: no-cache

Here is the response from the server:

以下是服务器的响应:

HTTP/1.1 405 Method Not Allowed
Cache-Control: private
Allow: POST
Content-Length: 1565
Content-Type: text/html; charset=UTF-8
Server: Microsoft-IIS/7.5
Set-Cookie: ASP.NET_SessionId=53pqdbqgtj2cfdvtqrikiewu; path=/; HttpOnly
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Access-Control-Allow-Origin: http://localhost:82
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Max-Age: 17280
Access-Control-Allow-Headers: content-type
Access-Control-Allow-Credentials: true
Date: Thu, 15 Sep 2011 15:55:27 GMT

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Service</title>
  </head>
  <body>
    <div id="content">
      <p class="heading1">Service</p>
      <p>Method not allowed.</p>
    </div>
  </body>
</html>

Any ideas?

1 个解决方案

#1


2  

Firefox sends an OPTIONS request in addition to a POST or GET.

除了POST或GET之外,Firefox还会发送OPTIONS请求。

See http://forums.iis.net/t/1160649.aspx for how to fix it.

有关如何解决此问题,请参见http://forums.iis.net/t/1160649.aspx。

Edit

The other thing that is special in your case is that you are using IIS 7.5 which does not allow all verbs by default.

在您的情况下,另一件特别的事情是您使用的是IIS 7.5,默认情况下不允许所有谓词。

You need to allow the OPTIONS verb

你需要允许OPTIONS动词

IIS 7.5, Web Service and HTTP 405 error

IIS 7.5,Web服务和HTTP 405错误

#1


2  

Firefox sends an OPTIONS request in addition to a POST or GET.

除了POST或GET之外,Firefox还会发送OPTIONS请求。

See http://forums.iis.net/t/1160649.aspx for how to fix it.

有关如何解决此问题,请参见http://forums.iis.net/t/1160649.aspx。

Edit

The other thing that is special in your case is that you are using IIS 7.5 which does not allow all verbs by default.

在您的情况下,另一件特别的事情是您使用的是IIS 7.5,默认情况下不允许所有谓词。

You need to allow the OPTIONS verb

你需要允许OPTIONS动词

IIS 7.5, Web Service and HTTP 405 error

IIS 7.5,Web服务和HTTP 405错误