Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

ow-to-return-http-500-from-asp-net-core-rc2-web-api

From what I can see there are helper methods inside the ControllerBase class. Just use the StatusCode method:

[HttpPost]
public IActionResult Post([FromBody] string something)
{    
    //...
    try
    {
        DoSomething();
    }
    catch(Exception e)
    {
         LogException(e);
         return StatusCode(500);
    }
}
You may also use the StatusCode(int statusCode, object value) overload which also negotiates the content.
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# check word length 
Csharp :: c# url relative path remove 
Csharp :: screenshot c# WinForms 
Csharp :: check the request comes from which operating system used by user in asp net core 
Csharp :: c# check number is odd or even 
Csharp :: how to if i enter 1 go to this program C# 
Csharp :: how to play a random sound at the position that you want in unity 
Csharp :: what is string args in c# 
Csharp :: how to call method in different project in c# visual studio 
Csharp :: C# count specific words in string 
Csharp :: unity how to get data of play session time in a text file? 
Csharp :: get image information using c# 
Csharp :: polymorphism in c# 
Csharp :: unity how to check object position 
Csharp :: convert memorystream to byte array c# 
Csharp :: thread c# 
Csharp :: c sharp or operator in if statement 
Csharp :: c# filesystemwatcher 
Csharp :: .Net 6 Program.cs 
Csharp :: how to use K2 games Games parallax background 
Csharp :: polling data source c# using threads 
Html :: open markdown link in new tab 
Html :: open link in new tab 
Html :: HP cmd get computer serial number 
Html :: html entity double quote 
Html :: fa fa globe 
Html :: link icon html 
Html :: youtube autoplay video 
Html :: html phone 
Html :: meta icon html 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =