我在这样的路线中检查身份验证:
private dynamic GetAll()
{
this.RequiresAuthentication();
var data = _tourRepository.GetAll();
return Response.AsJson(data);
}
如果用户未经过身份验证,则RequiresAuthentication()
会抛出错误 导致我进入管道的错误:
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
StaticConfiguration.DisableErrorTraces = false;
pipelines.OnError += (ctx, ex) =>
{
if (ex is RouteExecutionEarlyExitException)
return ((RouteExecutionEarlyExitException)ex).Response;
return new Response { StatusCode = HttpStatusCode.InternalServerError };
};
base.ApplicationStartup(container, pipelines);
}
我在这里做错了什么?