2

I m getting "405 Method Not Allowed" error for my angularjs application running on PHP over iis 8.5

These are my header request...

Access-Control-Allow-Headers:Content-Type, Accept
Access-Control-Allow-Methods:GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Origin:*
Allow:GET, HEAD, OPTIONS, TRACE

What i can see is that post is missing in "Allow:GET, HEAD, OPTIONS, TRACE"

Can any one guide me how to enable POST request in IIS 8.5.

Chrome screen shot

enter image description here

SOLVED

i finally solve this.... I guess the issue was in MY URL - api/login which is called in POST... i changes that URL with api/login/checklogin.php and executed POST request.... it works.......

SUPER THANKS TO LIN for his guidance and 
http://stackoverflow.com always gives you the best.... THANKS ALL..
Asad Ali Khan
  • 307
  • 4
  • 16
  • This is not a issue depending on your cors setup. CORS doesnt effect the http status code. – lin Apr 02 '17 at 12:45
  • how to correct it... i tried every method on IIS 8.5 but NO success till now... do you have any helpful link to share.. – Asad Ali Khan Apr 02 '17 at 12:46

1 Answers1

2

CORS do not effect the HTTP Status code > HTTP status codes effect cors. Taken from this answer you should allow all the HTTP-Request types in IIS you need.

For IIS 8.x try:

You could follow up this guide or make the following change in your applicationhost.configfile for your instance:

<system.webServer>
    <handlers>
        <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
        <remove name="OPTIONSVerbHandler" />
        <remove name="TRACEVerbHandler" />
        <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
</system.webServer>

Also ensure you removed WebDAV module from web.config (if installed and enabled):

<system.webServer>
  <modules>
    <remove name="WebDAVModule"/>
  </modules>
  <handlers>
    <remove name="WebDAV"/>
  </handlers>
</system.webServer>
Community
  • 1
  • 1
lin
  • 17,956
  • 4
  • 59
  • 83
  • i cannot see "WebDAV" see in my list but i can see all this "OPTIONSVerbHandler" – Asad Ali Khan Apr 02 '17 at 12:52
  • No brother... applicationhost.config this file is totally empty... i pasted you code in it... and retsrated server.... but same error... – Asad Ali Khan Apr 02 '17 at 13:02
  • Ensure you removed WebDAV module as provided in my answer. This should do it for you. – lin Apr 02 '17 at 13:03
  • now it gives error. http://surveys.odalternatives.com/admin/access/signin This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false". – Asad Ali Khan Apr 02 '17 at 13:05
  • 1
    http://stackoverflow.com/questions/9794985/iis-this-configuration-section-cannot-be-used-at-this-path-configuration-lock – lin Apr 02 '17 at 13:07
  • I did everything... "overrideMode="Deny" or the legacy " problem is gone... but "405 Method Not Allowed" is still there... please guide.. – Asad Ali Khan Apr 02 '17 at 14:20
  • @AsadAliKhan https://learn.microsoft.com/en-us/aspnet/web-api/overview/testing-and-debugging/troubleshooting-http-405-errors-after-publishing-web-api-applications – lin Apr 02 '17 at 14:41
  • Still Same error... I dont know where i m going wrong... you can view things at URL surveys.odalternatives.com/admin/access/signin Access-Control-Allow-Headers:Content-Type Access-Control-Allow-Methods:GET, POST, PUT, DELETE, OPTIONS Access-Control-Allow-Origin:* Allow:GET, HEAD, OPTIONS, TRACE – Asad Ali Khan Apr 02 '17 at 16:39
  • i finally solve this.... I guess the issue was in MY URL - api/login which is called in POST... i changes that URL with api/login/checklogin.php and executed POST request.... it works....... SUPER THANKS TO LIN for his guidance and http://stackoverflow.com always gives you the best.... THANKS ALL.. – Asad Ali Khan Apr 03 '17 at 04:59
  • @AsadAliKhan I thought it could be at last that kind of error. The Setup before was necessary too. Glad to help ya. – lin Apr 03 '17 at 09:59