Reputation: 4239
I'm creating an ASP .Net Core 2.2 Web API, and am implementing a controller action which will be invoked via a POST. However, when I run it in Debug mode in Visual Studio 2017, and I call the endpoint using Postman, I get a 405 Method Not Allowed
I specified that I am doing this in debug mode in VS because I've seen a couple of posts online where people are getting this issue when deploying, and having to remove WebDAV from IIS or adding this:
<system.webServer>
<modules runAllManagedModulesForAllRequests="false">
<remove name="WebDAVModule" />
</modules>
</system.webServer>
to their config.web
However, seeing as I am running from VS, it is using IIS Express, and there is no web.config file.
I haven't yet tried to publish the API, as it's not even working locally on my machine, so it feels wrong to publish something that's broken.
EDIT:
So my controller looks like this:
public class TestController : ControllerBase
{
public TestController()
{
}
[HttpPost]
private void Post()
{
Console.Write("TEST");
}
}
Upvotes: 1
Views: 6895
Reputation: 4239
As mentioned by the keen-eyed noobed, my problem was that my controller action was private and not public. Thanks again noobed.
Upvotes: 2