【发布时间】:2014-02-01 01:48:27
【问题描述】:
在尝试为我的 Web Api 项目(在 VS 2013 + .Net 4.5.1 中)启用 owin 和 AspNet Identity 后,我在每个有效或无效(对不存在控制器的请求)请求中都收到以下错误:
<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);
}
}
}
【问题讨论】:
标签: c# asp.net-mvc-5 owin windows-authentication