i have a SimplaKeyAuthorizeFilter
,in the filter
,will throw 401
public SimpleKeyAuthorize(IHttpRequest req, IHttpResponse res, object obj, bool isDebugMode){
throw new UnauthorizedAccessException("lack sign info!");
}
in the apphost:
this.ExceptionHandler = (httpReq, httpRes, operationName, ex) =>{
DtoUtils.CreateErrorResponse(httpReq, ex, new ResponseStatus() { ErrorCode = ex.ToErrorCode(), Message = ex.Message });
httpRes.Write(ex.ToErrorCode());
httpRes.EndRequest(skipHeaders:false);
};
........
this.RequestFilters.Add((req,res,obj)=>{
new SimpleKeyAuthorize(req,res,obj,false);
});
but when i call the service,the httpstatuscode is 200,is not 401,why?
HTTP/1.1 200 OK (why not 401?)
Cache-Control: private
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 14 Mar 2014 05:56:30 GMT
Content-Length: 27
UnauthorizedAccessException