Cross application navigation - The HTTP request is unauthorized with client authentication scheme 'Negotiate'
Published: 2023-01-08 19:07:15

My team have a legacy app running on asp.net .net framework 4.5 and one of the modules has been upgraded to a .net 6 Blazor application. We are experiencing authentication issues when navigating between these two applications. There does not seem to be any issue navigating to new application but when we try to navigate back to legacy app from new app, we get the below error. Both applications' authentication is handled by windows authentication. The issue usually starts after one successful return navigation, with all subsequent navigations failing. This includes any other new tab in the browser we have opened to retest as well as new windows. We must close all open browser windows to get it to work on the first nav again.


System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'. --->
System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
--- End of inner exception stack trace ---

Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory`1 factory)
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Internal.WSSecurity.IWSSecurity.UpdateLastloginDate(UpdateLastloginDateRequest request)
at Internal.Index.Page_Load(Object sender, EventArgs e) in C:\0 - SOURCE CODE\
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


In our DEV environment, both the UIs and the services are hosted on one server but under four app pools, one for each item (the two UIs and their related service). In our QA environment, both UIs are hosted on one server but under two app pools, and the Services are hosted on another server, again running under two app pools. The issue is not reproducible when ran locally in debug mode, and the issue only shows up on our hosted websites.