突然之间,我在自托管的ServiceStack WS中不断出现HTTP 500错误。
我已经有几个请求了,它们工作正常,但是这个请求是行不通的。我已经这样添加了我的许可证:
private void StartServiceStackService()
{
Licensing.RegisterLicenseFromFileIfExists("servicestack-license.txt".MapHostAbsolutePath());
_serviceStackHost = new ServiceStackWsHost(this, _frontEndModuleParameters, _alfaWebServicesSettings);
_serviceStackHost.Init();
if (!Debugger.IsAttached)
{
_serviceStackHost.Start(new[] { "http://+:8080/" });
}
else
{
_serviceStackHost.Start(new[] { "http://+:8081/" });
}
}
失败的服务是:
[Route(Bookings.BASE_PATH + "search", Verbs = "GET")]
public class SearchAddress : IReturn<SearchAddressResponse>
{
public string SearchString { get; set; }
}
public class SearchAddressResponse : ResponseBase
{
public string Test { get; set; }
// public List<Address> Addresses { get; set; }
}
internal class SearchAddressHandler : ServiceHandlerBase
{
public SearchAddressResponse Get(SearchAddress searchAddress)
{
return new SearchAddressResponse()
{
Test = "ASDASDASD"
};
}
}
我用Fiddler4这样称呼它:
GET http://192.168.0.147:8081/alfaonline/bookings/search?SearchString=123 HTTP/1.1
User-Agent: Fiddler
Host: 192.168.0.147:8081
AuthToken: a18b613c-23b2-4f4e-8934-ad8d6cbc57bb
DeviceUUID: 1baaace
并获得此回复:
HTTP/1.1 500 Internal Server Error
Transfer-Encoding: chunked
Content-Type: text/html
Vary: Accept
Server: Microsoft-HTTPAPI/2.0
X-Powered-By: ServiceStack/5.20 Net45/Windows
Date: Wed, 26 Sep 2018 11:28:31 GMT
0
如果我改为返回“ null”,则这样:
[MyAuthenticate]
internal class SearchAddressHandler : ServiceHandlerBase
{
public SearchAddressResponse Get(SearchAddress searchAddress)
{
return null;
}
}
提琴手给我HTTP 204 OK:
HTTP/1.1 204 OK
Content-Length: 0
Vary: Accept
Server: Microsoft-HTTPAPI/2.0
X-Powered-By: ServiceStack/5.20 Net45/Windows
Date: Wed, 26 Sep 2018 11:26:29 GMT
我没有看到任何错误,VS在调试模式下的异常以及在“异常”设置中的“全部捕获”。我可以在处理程序中放置一个断点,然后在该处中断,以便执行正确的处理程序。
更新我一直在使用Fiddler,现在正在运行Fiddler4。当我尝试如下所述的服务时,例如在swagger(ServiceStack插件)中,它按预期运行。如果我在Postman中运行该服务,它将按预期运行。但是,如果我在Fiddler中运行它,则会得到HTTP 500
更新2 我也刚刚注意到,转到http://127.0.0.1:8081/requestlogs也会产生HTTP 500错误。更具体地说,当我访问/ requestlogs并添加UncaughtExceptionHandlers时,我看到此错误:
System.MissingMethodException:找不到方法:'System.String ServiceStack.StringUtils.HtmlEncodeLite(System.String)'。在 ServiceStack.Formats.HtmlFormat.d__10.MoveNext() 在 System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start [TStateMachine](TStateMachine& stateMachine)在 ServiceStack.Formats.HtmlFormat.SerializeToStreamAsync(IRequest req, 对象响应,流outputStream)在 ServiceStack.HttpResponseExtensionsInternal.d__7.MoveNext()
答案 0 :(得分:1)
您的第一种方法应该是获取有关错误的信息:
ResponseStatus
属性,