0
votes

I am working on a web api in C# and I am confortable with HttpResponseMessage return type GET and POST functions(return Request.CreateResponse(HttpStatusCode.Ok,"message")) as it gives me flexibility to throw httpstatuscode with messages; what happens is when I create an ASP NET WEB API project, all of the above works but there is no startup.cs file or appsettings.json file to configure ApplicationInsights for logging;

So, I added startup.cs(OWIN packages too); but then the code broke and after lot of searching I gave up and created a new ASP NET CORE WEB API project; now it has got startup.cs and appsettings.json but it doesn't accept my request and response requirements in the Controller file; To use Request.CreateResponse() I have to install Microsoft.AspNet.WebApi package, change the base class from ControllerBase to ApiController but when I send a post request using POSTMAN ,the request is not getting captured. So, how to get out of this mess?

1
You need to provide more information, such as screenshots of the project structure directory. And now the question is do you want to implement the functions you described earlier in the dotnet core project?Jason Pan

1 Answers

0
votes

In ASP.NET Core you usually just have to

return Ok();

All response codes are built into

namespace Microsoft.AspNetCore.Mvc

See here for examples, and here for all result types.