简体   繁体   English

请求失败,HTTP状态为401:未授权。

[英]The request failed with HTTP status 401: Unauthorized.

When I am calling a web service on Windows 10 v1607 it works fine for me, but when I try the same web service on Windows 10 v1703, it gives me this error: 当我在Windows 10 v1607上调用Web服务时,它对我来说很好用,但是当我在Windows 10 v1703上尝试相同的Web服务时,它给了我这个错误:

The request failed with HTTP status 401: Unauthorized. 
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

 Exception Details: System.Net.WebException: The request failed with HTTP status 401: Unauthorized.

Source Error: 


 An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 



[WebException: The request failed with HTTP status 401: Unauthorized.]
   System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +237136
   System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +267
   CPR.Apps.CPMS.ServiceWrapper.CPMSProxy.CPMSService.GetUserGroupTasks(User& user) +138
   CPR.Apps.CPMS.ServiceWrapper.WebAppServiceWrapper.GetUserGroupTasks(User& cpmsUser) +111
   CCPS.App.Web.UI.Global.Session_Start(Object sender, EventArgs e) +145
   System.Web.SessionState.SessionStateModule.CompleteAcquireState() +380
   System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +1250
   System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +631
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +134

Please note that it works if I set the web service authentication to be anonymous, but this is not acceptable from a security standpoint. 请注意,如果我将Web服务身份验证设置为匿名,则该方法有效,但是从安全角度来看,这是不可接受的。 Presently, the security settings are asp.net impersonation and windows authentication. 当前,安全设置为asp.net模拟和Windows身份验证。

Also, I have webService.UseDefaultCredentials = true . 另外,我有webService.UseDefaultCredentials = true

Does anyone have any suggestions? 有没有人有什么建议?

OK, found the problem--the Visual Studio solution had for the web app properties Web -> Servers -> IIS Express with a value like http://localhost:51243 which works fine for debugging, but when I publish it keeps those settings so it will not work on the production server. 好的,找到了问题-Visual Studio解决方案的Web应用程序属性Web > Servers > IIS Express具有类似http://localhost:51243 ,可以很好地进行调试,但是当我发布它时,保留这些设置因此它将无法在生产服务器上运行。

To resolve the issue, I switched it to External Host with the production URL. 要解决此问题,我使用生产URL将其切换到了External Host

I still find it interesting that Windows 10 v1607 doesn't care about this while v1703 gives the 401 error. 我仍然发现有趣的是Windows 10 v1607对此并不关心,而v1703却显示401错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 请求失败,HTTP 状态为 401:未授权 IN SSRS - The request failed with HTTP status 401: Unauthorized IN SSRS 请求失败,HTTP状态为401:未经授权 - The request failed with HTTP status 401: Unauthorized 错误请求失败,HTTP状态为401:未经授权 - Error The request failed with HTTP status 401: Unauthorized 请求失败,HTTP 状态为 401:调用 Web 服务时未经授权 - The request failed with HTTP status 401: Unauthorized while calling web service 请求失败,HTTP状态为401:再次尝试未授权 - Request failed with HTTP status 401: Unauthorized on second try 服务器无法处理请求。 --->请求失败,HTTP状态为401:未经授权 - Server was unable to process request. ---> The request failed with HTTP status 401: Unauthorized 在C#窗口应用程序中SSRS报告呈现中出现错误:请求失败,HTTP状态为401:未经授权 - Getting Error in SSRS report rendering in C# window application: The request failed with HTTP status 401: Unauthorized 请求失败,HTTP状态为401:未授权 - IIS升级 - WebService和Web应用程序 - The request failed with HTTP status 401: Unauthorized - IIS Upgrade - WebService & Web Application 远程服务器返回错误:(401) Unauthorized。 Twitter oAuth - The remote server returned an error: (401) Unauthorized. Twitter oAuth 远程服务器返回错误:(401)未经授权。 wcf httpbinding基本 - The remote server returned an error: (401) Unauthorized. wcf httpbinding basic
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM