【发布时间】:2016-10-06 05:55:10
【问题描述】:
创建了一个自定义 Web 服务,该服务部署为 SP2013 的场解决方案。在 VS 项目中为该服务添加了 ISAPI 文件夹的托管路径。
添加了 C:\inetpub\wwwroot\wss\VirtualDirectories\80
<location path="_vti_bin/FCWebServices.svc">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
还添加了 C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\web.config
<location path="FCWebServices.svc">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
从 IE 或 Chrome 调用适当的路径“http://host/_vti_bin/FCWebServices.svc/GetOffCanvasNavigation”——我得到一个 HTTP 200 的预期数据。从 JQuery $.ajax 调用我得到一个 401(只是调用 web 服务方法本身,甚至注释掉任何 SP2013 API 调用)。
我希望此 Web 服务调用是匿名的,它将在面向公众的 SharePoint 2013 网站上进行。
这是网络请求的标头转储:
Request URL: http://host/_vti_bin/FCWebServices.svc/GetOffCanvasNavigation
Request Method: OPTIONS
Status Code: 401 / Unauthorized
- Request Headers
Accept: */*
Accept-Encoding: gzip, deflate
Access-Control-Request-Headers: content-type, accept
Access-Control-Request-Method: GET
Cache-Control: no-cache
Connection: Keep-Alive
Content-Length: 0
Host: fcit-mcvm2
Origin: file:
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586
- Response Headers
Access-Control-Allow-Origin: *
Content-Length: 16
Content-Type: text/plain; charset=utf-8
Date: Mon, 06 Jun 2016 14:50:50 GMT
Location: /_login/default.aspx?ReturnUrl=%2f_vti_bin%2fFCWebServices.svc%2fGetOffCanvasNavigation
MicrosoftSharePointTeamServices: 15.0.0.4569
request-id: eb85839d-472b-d06e-9fc9-c1e40fcec15a
Server: Microsoft-IIS/8.5
SPIisLatency: 155
SPRequestDuration: 1336
SPRequestGuid: eb85839d-472b-d06e-9fc9-c1e40fcec15a
WWW-Authenticate: NTLM
X-Content-Type-Options: nosniff
X-FRAME-OPTIONS: SAMEORIGIN
X-MS-InvokeApp: 1; RequireReadOnly
X-Powered-By: ASP.NET
记录控制台错误:
HTTP401: DENIED - The requested resource requires user authentication.
(XHR): OPTIONS - http://host/_vti_bin/FCWebServices.svc/GetOffCanvasNavigation
有什么想法可以消除 401 吗?
标记
【问题讨论】:
标签: wcf sharepoint-2013