简体   繁体   中英

Web API Getting 401 Unauthorized in IIS but works in IIS Express

I have a Web API project that makes a remote SOAP call. This works fine in IIS Express (win 7) but it does not work in either IIS 7.5 (win 7) or IIS 8.5 (wind server 2012 R2).

Here's the response in IIS Express

{
Content-Length: 429
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Date: Wed, 16 Mar 2016 23:00:52 GMT
Server: Microsoft-IIS/7.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
}

And here is the response in IIS 7.5

{Content-Type: text/html
Server: Microsoft-IIS/7.0
WWW-Authenticate: Negotiate,NTLM
X-Powered-By: ASP.NET
Date: Wed, 16 Mar 2016 22:13:10 GMT
Content-Length: 1293

}

I've disabled Windows Authentication and enabled only Anonymous authentication in IIS 7.5

In fact, I've also done a WinDiff of applicationHost.config and copied over settings that are different (and applicable) from IIS Express to IIS 7.

Web.Config has <Authentication mode ="None">

I'm not sure what I have to do to get this working.

EDIT SOLVED ALREADY

This SO post lead me to the answer. And this SO post is how I am passing the credentials.

The response from IIS clearly indicates that Windows authentication is enabled. Check the IIS configuration carefully please.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM