© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
13 replies
SWEETPONY

❔ What should web api controller return?

I can return Ok with some json as parameter. Or I can return simple string

For example, I have method in controller:
[HttpGet("movies")]
public string GetMovies()
   => "12 angry men";
[HttpGet("movies")]
public string GetMovies()
   => "12 angry men";


Is it correct to return just a string?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

✅ Web API Controller Response JObject
C#CC# / help
2y ago
What should the service layer return back to a controller?
C#CC# / help
2y ago
✅ Implementing delete repository method & controller | Web Api
C#CC# / help
13mo ago