Ex.ToErrorCode error

@ali qq duoshao hao jiao liu
when I visit below

 [Authenticate]
    [Route("/h2")]
    [Route("/h2/{Name}")]
    public class H2 : IReturn<HelloResponse>
    {
        public string Name { get; set; }
    }

{“ResponseStatus”:{“ErrorCode”:“NullReferenceException”,“Message”:“未将对象引用设置到对象的实例。”,“StackTrace”:" 在 ServiceStack.HttpRequestExtensions.ToErrorCode(Exception ex)\r\n 在 ServiceStack.HttpResponseExtensionsInternal.ToErrorResponse(Exception ex)\r\n 在 ServiceStack.HttpResponseExtensionsInternal.WriteErrorToResponse(IResponse httpRes, IRequest httpReq, String contentType, String operationName, String errorMessage, Exception ex, Int32 statusCode)\r\n 在 ServiceStack.HttpResponseExtensionsInternal.WriteError(IResponse httpRes, IRequest httpReq, Object dto, String errorMessage)\r\n 在 ServiceStack.AuthenticateAttribute.Execute(IRequest req, IResponse res, Object requestDto)\r\n 在 ServiceStack.RequestFilterAttribute.RequestFilter(IRequest req, IResponse res, Object requestDto)\r\n 在 ServiceStack.ServiceStackHost.ApplyRequestFiltersSingle(IRequest req, IResponse res, Object requestDto)\r\n 在 ServiceStack.ServiceStackHost.ApplyRequestFilters(IRequest req, IResponse res, Object requestDto)\r\n 在 ServiceStack.Host.RestHandler.ProcessRequestAsync(IRequest httpReq, IResponse httpRes, String operationName)"}}

    public static string ToErrorCode(this Exception ex)  // ex  is null so ex.GetType() error
        {
            var hasErrorCode = ex as IHasErrorCode;
            return (hasErrorCode != null ? hasErrorCode.ErrorCode : null)
                ?? ex.GetType().Name;
        }

It’s recommended your Request DTOs not have any implementation like Request Filters. Can you try move the [Authenticate] attribute on the Service class implementation instead to see if that resolves the issue? e.g:

[Route("/h2")]
[Route("/h2/{Name}")]
public class H2 : IReturn<HelloResponse>
{
    public string Name { get; set; }
}

[Authenticate] //Move to Service implementation
public class H2Services : Service
{
    public object Any(H2 request)
    {
    }
}

@lsl my qq is 156738161 .

when put [Authenticate] on Service or Any method , both throw error on ServiceStack.HttpRequestExtensions.ToErrorCode(Exception ex)

Ok then I’ll need a small standalone repro, this doesn’t happen normally.