Я пытаюсь вернуть другой статус для веб-метода - но похоже, что соединение получает сброс, или я не получаю свое изменение статуса (и остается с 200)
public interface IService
{
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate ="MyMethod?val={val}",
ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
string MyMethod(int v);
}
public class MyService : IService
{
[WebMethod]
public string MyMethod(int v)
{
if (v > 10)
{
var res = HttpContext.Current.Response;
res.Clear();
res.StatusCode = 400; // or whatever code is appropriate
res.StatusDescription = "don't send anything over 10!";
res.Write("nothing over 10");
res.Flush();
res.End();
return null;
}
return "good answer";
}
}
если я удаляю «flush / end», я получаю 200 и все, что я послал, если я сохраняю их, я получаю сброс соединения на стороне клиента.
есть идеи?