ASP.NET Core Web API 500 Internal Server Error


Fear

I am trying to build an API within the ASP.NET Core framework. I made a basic controller that just returns a string:

namespace Dojo_Api.Controllers.Forum
{
    //[Authorize]
    [Route("api/[controller")]
    public class ForumController : Controller
    {
        private MainContext _context;

        public ForumController(MainContext context)
        {
            _context = context;
        }

        [HttpGet]
        public string Get()
        {
            return "string";
        }
    }
}

Now when I try to access the API via postman I get a 500 Internal Server Error:

enter image description here

I've tried changing the port, but it didn't work. Does anyone know a solution to this problem?

Thanks in advance!

Nkosi

[Route("api/[controller")]Unless it's a typo when writing the question, the controller route is missing the closing square bracket here .

it should be

[Route("api/[controller]")]
public class ForumController : Controller { ... }

Related


Asp.Net Core 2 Web API 500 Internal Server Error

Anil When I try to access the API through postman, send: localhost:5050/api/Auth/token body: {“ UserName”:“ jouverc”,“ Password”:“ P @ ssw0rd!” } This method: [Produces("application/json")] [Route("api/Auth")] public class AuthController : Controller { #r

Asp.Net Core 2 Web API 500 Internal Server Error

Anil When I try to access the API through postman, send: localhost:5050/api/Auth/token body: {“ UserName”:“ jouverc”,“ Password”:“ P @ ssw0rd!” } This method: [Produces("application/json")] [Route("api/Auth")] public class AuthController : Controller { #r

Asp.Net Core 2 Web API 500 Internal Server Error

Anil When I try to access the API through postman, send: localhost:5050/api/Auth/token body: {“ UserName”:“ jouverc”,“ Password”:“ P @ ssw0rd!” } This method: [Produces("application/json")] [Route("api/Auth")] public class AuthController : Controller { #r

Asp.Net Core 2 Web API 500 Internal Server Error

Anil When I try to access the API through postman, send: localhost:5050/api/Auth/token body: {“ UserName”:“ jouverc”,“ Password”:“ P @ ssw0rd!” } This method: [Produces("application/json")] [Route("api/Auth")] public class AuthController : Controller { #r

Asp.Net Core 2 Web API 500 Internal Server Error

Anil When I try to access the API through postman, send: localhost:5050/api/Auth/token body: {“ UserName”:“ jouverc”,“ Password”:“ P @ ssw0rd!” } This method: [Produces("application/json")] [Route("api/Auth")] public class AuthController : Controller { #r

Asp.Net Core 2 Web API 500 Internal Server Error

Anil When I try to access the API through postman, send: localhost:5050/api/Auth/token Body: {“ UserName”:“ jouverc”,“ Password”:“ P @ ssw0rd!” } This method: [Produces("application/json")] [Route("api/Auth")] public class AuthController : Controller { #r

Asp.Net Core 2 Web API 500 Internal Server Error

Anil When I try to access the API through postman, send: localhost:5050/api/Auth/token Body: {“ UserName”:“ jouverc”,“ Password”:“ P @ ssw0rd!” } This method: [Produces("application/json")] [Route("api/Auth")] public class AuthController : Controller { #r

Asp.Net Core 2 Web API 500 Internal Server Error

Anil When I try to access the API through postman, send: localhost:5050/api/Auth/token Body: {“ UserName”:“ jouverc”,“ Password”:“ P @ ssw0rd!” } This method: [Produces("application/json")] [Route("api/Auth")] public class AuthController : Controller { #r

Asp.Net Core 2 Web API 500 Internal Server Error

Anil When I try to access the API through postman, send: localhost:5050/api/Auth/token Body: {“ UserName”:“ jouverc”,“ Password”:“ P @ ssw0rd!” } This method: [Produces("application/json")] [Route("api/Auth")] public class AuthController : Controller { #r

ASP.NET Core hosting - 500 Internal Server Error

username I'm trying to publish as an ASP.NET Core project using a hosting provider that supports ASP.NET Core. I get a 500 Internal Server Error, which is pretty common. So I searched on the internet and various forums and checked processPath="%LAUNCHER_PATH%"

ASP.NET Core hosting - 500 Internal Server Error

username I'm trying to publish as an ASP.NET Core project using a hosting provider that supports ASP.NET Core. I get a 500 Internal Server Error, which is pretty common. So I searched on the internet and various forums and checked processPath="%LAUNCHER_PATH%"

ASP.NET Core hosting - 500 Internal Server Error

username I'm trying to publish as an ASP.NET Core project using a hosting provider that supports ASP.NET Core. I get a 500 Internal Server Error, which is pretty common. So I searched on the internet and various forums and checked processPath="%LAUNCHER_PATH%"

ASP.NET Core hosting - 500 Internal Server Error

username I'm trying to publish as an ASP.NET Core project using a hosting provider that supports ASP.NET Core. I get a 500 Internal Server Error, which is pretty common. So I searched on the internet and various forums and checked processPath="%LAUNCHER_PATH%"

ASP.NET Core hosting - 500 Internal Server Error

username I'm trying to publish as an ASP.NET Core project using a hosting provider that supports ASP.NET Core. I get a 500 Internal Server Error, which is pretty common. So I searched on the internet and various forums and checked processPath="%LAUNCHER_PATH%"

ASP.NET Core hosting - 500 Internal Server Error

username I'm trying to publish as an ASP.NET Core project using a hosting provider that supports ASP.NET Core. I get a 500 Internal Server Error, which is pretty common. So I searched on the internet and various forums and checked processPath="%LAUNCHER_PATH%"

asp.net core application. 500 Internal Server Error

David Edel I uploaded my website to godaddy windows hosted with plesk. All files are uploaded but I get an error: 500 Internal Server Error. There is a problem with the resource you are looking for and cannot be displayed. By researching the problem online, I

ASP.NET Core API-500 Internal Server Error, in production only

facelift I have developed an ASP.NET WebApi application. When I publish and test it to localhost IIS I get this error on one request: Response with status: 500 Internal Server Error for URL: http://localhost/api/COMI/NEW/158/3 web.config: <?xml vers

ASP.NET Core API-500 Internal Server Error, in production only

facelift I have developed an ASP.NET WebApi application. When I publish and test it to localhost IIS I get this error on one request: Response with status: 500 Internal Server Error for URL: http://localhost/api/COMI/NEW/158/3 web.config: <?xml vers

ASP.NET Core API-500 Internal Server Error, in production only

facelift I have developed an ASP.NET WebApi application. When I publish and test it to localhost IIS I get this error on one request: Response with status: 500 Internal Server Error for URL: http://localhost/api/COMI/NEW/158/3 web.config: <?xml vers

ASP.NET Core API-500 Internal Server Error, in production only

facelift I have developed an ASP.NET WebApi application. When I publish and test it to localhost IIS I get this error on one request: Response with status: 500 Internal Server Error for URL: http://localhost/api/COMI/NEW/158/3 web.config: <?xml vers

ASP.NET Core API-500 Internal Server Error, in production only

facelift I have developed an ASP.NET WebApi application. When I publish and test it to localhost IIS I get this error on one request: Response with status: 500 Internal Server Error for URL: http://localhost/api/COMI/NEW/158/3 web.config: <?xml vers