0

I have published angular 7 with entity framework core application on server but only http POST method is working other http methods like DELETE and PUTthrow below error:

Http failure during parsing for " and "Unexpected token < in JSON at position 0

Previously it was working on another server where i published but when I published same application to new server then DELETE and PUT methods throw error.

1) I tried given possible solutions like putting "responseType": 'text' in header

2) Putting "Access-Control-Allow-Methods": "GET, PUT, POST, DELETE, OPTIONS" in header but nothing has solved the problem

Ankit Vijay
  • 3,752
  • 4
  • 30
  • 53
  • Possible duplicate of [ASP.NET Web API - PUT & DELETE Verbs Not Allowed - IIS 8](https://stackoverflow.com/questions/10906411/asp-net-web-api-put-delete-verbs-not-allowed-iis-8) – krillgar May 31 '19 at 10:13

1 Answers1

0

Check your Allowed Verbs on your server. Typically only GET and POST are allowed by default. Especially with IIS, DELETE and PUT are not enabled.

krillgar
  • 12,596
  • 6
  • 50
  • 86
  • Is there any other way to solve this issue? Because server administrator is not agree to do any changes on server. – Machhindra Gaikwad May 30 '19 at 08:07
  • I changed it with application web.config but nothing has solved – Machhindra Gaikwad May 30 '19 at 09:06
  • The same code is working on another server without any issue, does anyone know the possible solution? – Machhindra Gaikwad May 30 '19 at 09:07
  • `The same code is working on another server without any issue`, then that points to an issue on that server. Those settings should only be on that App Pool, iirc. Sorry, but your server admin is most likely going to need to make some configuration changes. – krillgar May 30 '19 at 10:09
  • server administrator is agree to do configuration changes on server, does any one know what to do exactly on server or iis to get rid of the issue? (when calling http put function response is in html text format instead of json) Please help – Machhindra Gaikwad May 30 '19 at 15:12
  • Finally i got solution, error was GET "Rejected by UrlScan" Please check answer given by @DHFW https://stackoverflow.com/questions/10906411/asp-net-web-api-put-delete-verbs-not-allowed-iis-8 – Machhindra Gaikwad May 31 '19 at 06:47