最佳答案
在尝试为我的 Web Api 项目启用 owin & AspNet Identity 之后(在 VS 2013 + 中)。Net 4.5.1)在每个有效或无效(对不存在控制器的请求)请求中,我得到以下错误:
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
No OWIN authentication manager is associated with the request.
</ExceptionMessage>
<ExceptionType>System.InvalidOperationException</ExceptionType>
<StackTrace>
at System.Web.Http.Owin.PassiveAuthenticationMessageHandler.SuppressDefaultAuthenticationChallenges(HttpRequestMessage request) at System.Web.Http.Owin.PassiveAuthenticationMessageHandler.<SendAsync>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at System.Web.Http.HttpServer.<SendAsync>d__0.MoveNext()
</StackTrace>
</Error>
当我在调试模式中检查时,也没有处理任何异常!此外,我还意识到 Startup
类中的 Configuration
从未被调用(实际上从未被调试器捕获)。以下是启动代码:
[assembly: OwinStartup(typeof(bloob.bloob.Startup))]
namespace bloob.bloob
{
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
}
}
}