Abhishek Dhotre
Abhishek Dhotre

Reputation: 511

.net core 500 internal server error after adding new api controller

I have created a .net core application which currently has one api controller and everything works fine. The problem is when I add another api controller to the solution with a different name and route. If I try to to run the APIs I get 500 internal server error once I add another controller. If I remove the newly added api controller everything works fine again. Any help would be appreciated!

Upvotes: 0

Views: 2094

Answers (1)

Abhishek Dhotre
Abhishek Dhotre

Reputation: 511

Seems like the problem is with the name (Name = "Get") attribute added to HttpGet method was the problem. All the controllers had the same Name attribute and hence the error. Removing the Name attribute from controllers solved the problem.

    [HttpGet("{id}", Name = "Get")]
    public string Get(int id)
    {
        return "value";
    }

Upvotes: 1

Related Questions