3

I'm rather new to everything so I'm hoping this is an easy fix!

I've written an API that uses basic authentication. It works wonderfully on local host, when I try to make a GET call from my browser it will popup asking for my username/password. I enter it and it does what is should.

However, after I publish it to our server it stops working. If I do the same thing it just returns an error rather than a challenge.

Here is what it returns on the server side.

An error has occurred.

No OWIN authentication manager is associated with the request.

System.InvalidOperationException

at System.Web.Http.Owin.PassiveAuthenticationMessageHandler.SuppressDefaultAuthenticationChallenges(HttpRequestMessage request) at System.Web.Http.Owin.PassiveAuthenticationMessageHandler.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at System.Web.Http.HttpServer.d__0.MoveNext()

Kurohoshi
  • 103
  • 3
  • 12
  • does [this answer](http://stackoverflow.com/questions/21089196/no-owin-authentication-manager-is-associated-with-the-request) fix it? – Jonesopolis Jul 24 '14 at 17:29
  • @Jonesy Sorry I should have linked that in my post. I did read that but from all I can tell that resource is getting built into my project. Although there is every chance that I am just missing something. – Kurohoshi Jul 24 '14 at 17:32
  • so the `Microsoft.Owin.Host.SystemWeb` dll is in your bin folder on the server? Are you hosting it with IIS? – Jonesopolis Jul 24 '14 at 17:36
  • It must be something to do with your owin host, but I'm not sure what then :-/ – Jonesopolis Jul 24 '14 at 17:41

1 Answers1

0

I'm not sure that this is a good solution but I managed to solve the problem.

After reading this https://katanaproject.codeplex.com/discussions/531740

I added <modules runAllManagedModulesForAllRequests="true"> In the web config.

Which gave me the username/password prompt that I needed.

After fixing that I realized that having Basic Authentication turned on in the IIS settings was causing it to loop the login prompt. Once I turned it off there I had no more problems.

Hope this helps if anyone else gets in this situation.

Kurohoshi
  • 103
  • 3
  • 12