I am writing a Web API to receive the telemetry data. The telemetry data in the form of hex string shall be POST to the web API URL. There is no authentication, no RoutePrefix and no Route needed for this Web API. The Content-Type: text/plain
Here is the my coding.
[Route("")]
[EnableCors(origins: "*", headers: "*", methods: "*")]
public class MyData_Controller : ApiController
{
[HttpPost]
[ActionName("DefaultAction")]
public Task<IHttpActionResult> DataPost(String myData)
{
SaveData(myData);
return Task.FromResult<IHttpActionResult>(Json(true));
}
protected void SaveData(String myData)
{
}
}
then I hosted this WebAPI to the IIS8.5. In web.config, I also added the following
<system.webServer>
<handlers accessPolicy="Read, Execute, Script">
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<remove name="WebDAV" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*."
verb="GET,HEAD,POST,PUT"
type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Execute" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
</system.webServer>
When I test it using POST in Postman, I get the the following error
HTTP Error 405.0 - Method Not Allowed
The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.
Detailed Error Information:
Module DirectoryListingModule
Notification ExecuteRequestHandler
Handler StaticFile
Error Code 0x80070001
Requested URL http://MyDataServer.com:2331/
Physical Path E:\Applications\Web API\MyDataServer_WebAPI
Logon Method Anonymous
Logon User Anonymous
Postman header shows
Allow → GET, HEAD, OPTIONS, TRACE
Does it mean that verb POST or PUT are not enabled?
I checked StaticFile handler and it is configured in the Handler Mappings and Requested Restrictions -> Verbs has All verbs selected.
What is wrong with my implementation and site configuration?