在尝试对我的Web Api项目启用owin和AspNet身份(在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>
当我在调试模式下检查时,也不会处理任何异常!我也意识到Configuration
在Startup
类中永远不会被调用(实际上从来不会被调试器捕获)。这是启动代码:
[assembly: OwinStartup(typeof(bloob.bloob.Startup))]
namespace bloob.bloob
{
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
}
}
}