无法在Google Chrome中制作删除和投放请求

时间:2017-01-16 10:13:51

标签: ajax asp.net-web-api2 preflight

您好我正在开发web api2 vs2015中的服务。最初我有发行我的固定和http动词,如获取,删除,放置,发布在mozilla和Internet Explorer中工作正常。我在谷歌浏览器中收到错误的put和delete请求。我无法在谷歌浏览器中执行put和delete。这是我在chrome中的请求和响应值。

Request URL:http://192.168.0.213:8041/User_Creation/1019
Request Method:OPTIONS
Status Code:400 Bad Request
Remote Address:192.168.0.213:8041
**Response Headers**
view source
Cache-Control:no-cache
Content-Length:58
Content-Type:application/json; charset=utf-8
Date:Mon, 16 Jan 2017 10:07:04 GMT
Expires:-1
Pragma:no-cache
Server:Microsoft-IIS/8.5
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET
**Request Headers**
view source
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
Access-Control-Request-Headers:
Access-Control-Request-Method:DELETE
Connection:keep-alive
Host:192.168.0.213:8041
Origin:http://192.168.0.213:8040
Referer:http://192.168.0.213:8040/usercreation/Index
User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36

我在web.config

中有以下代码行
 <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Methods" value="POST, PUT, DELETE, GET, OPTIONS" />
        <add name="Access-Control-Allow-Headers" value="content-Type, accept, origin, X-Requested-With, Authorization, name" />
        <add name="Access-Control-Allow-Credentials" value="true" />
      </customHeaders>
      </httpProtocol>

我在这里遗漏了什么吗?

我发送请求删除http动词,在第3行我可以看到选项动词。我在这里很困惑。我可以知道如何解决这个问题?谢谢你的帮助。

0 个答案:

没有答案
相关问题