Peurr Peurr - 1 year ago 283
ASP.NET (C#) Question

ASP.NET Core Web API 500 Internal Server Error

I'm trying to build an API within the ASP.NET Core framework. I've made a basic controller which just returns a string:

namespace Dojo_Api.Controllers.Forum
public class ForumController : Controller
private MainContext _context;

public ForumController(MainContext context)
_context = context;

public string Get()
return "string";

Now when I try to access the API via Postman, I receive a 500 Internal Server Error:

enter image description here

I have already tried changing the port, which didn't work. Does anyone know a solution for this problem?

Thanks in advance!

Answer Source

Controller route missing a closing square bracket here [Route("api/[controller")] unless that was a typo when question was written.

it should be

public class ForumController : Controller { ... }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download