0
AuthenticationFilerから401 Unauthorizedを返す必要がありますが、何らかの理由でHttpResponseExceptionをスローすると、302 Foundが返され、login.aspxにリダイレクトされます。WebAPI 2 IAuthenticationFilter return 401
public class MyAuthenticationFilterAttribute : Attribute, IAuthenticationFilter
{
public bool AllowMultiple { get { return false; } }
public async Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken)
{
Trace.TraceInformation("Authenticate");
throw new HttpResponseException(HttpStatusCode.Unauthorized);
}
public Task ChallengeAsync(HttpAuthenticationChallengeContext context, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}
と私はちょうどどのように適切にAuthenticationFilerから401権限を返すことができStartup.cs
でそれを登録します。ここでは
は私のフィルタの例でありますか?
、例外は高価です。あなたはそれらを最小限に保つために:) – gldraphael