core icon indicating copy to clipboard operation
core copied to clipboard

Can not return customize Http Status code.

Open ngoctubk opened this issue 8 years ago • 4 comments

Can not return customize Http Status code.

I have to return customize Http Status code like 11, 22, 99... but I catch Error: read ECONNRESET

Code and Issue

public IActionResult MyMethod()
{
     return StatusCode(99);
}

When I use Postman call, result return:

Could not get any response There was an error connecting to http://localhost:4015/api/values/5. Why this might have happened: The server couldn't send a response: Ensure that the backend is working properly Self-signed SSL certificates are being blocked: Fix this by turning off 'SSL certificate verification' in Settings > General Proxy configured incorrectly Ensure that proxy is configured correctly in Settings > Proxy Request timeout: Change request timeout in Settings > General

Postman console show Error:

Error: read ECONNRESET

Please show me how to do this.

In .net framework I can perform like: return Content((StatusCode)99, myObject);

ngoctubk avatar Sep 25 '18 10:09 ngoctubk

@ngoctubk does this happen if you return a standard status code such as 200? Or only with the non-standard ones?

Tagging @Tratcher in case you've seen something like this...

Eilon avatar Oct 03 '18 00:10 Eilon

@Eilon It's OK with standard status code when I'm using:

  • return NoContent();
  • return OK(object);
  • return CreatedAtAction(...) .... I't only happen when I use StatusCode() with non-standard one.

ngoctubk avatar Oct 03 '18 01:10 ngoctubk

Values less than 100 are invalid. Where are you getting those?

Tratcher avatar Oct 03 '18 02:10 Tratcher

Oh, I don't know that values less than 100 are invalid. Thank you!

ngoctubk avatar Oct 03 '18 02:10 ngoctubk