4

I've written code for file upload and download using HttpWebRequest/HttpWebResponse class in C# with Apache 2.2 as a web server. In code I'm using request.method = "PUT".

I want to config my HTTP config file to support PUT method. I write PUT method script as:

<Location "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/output">
<Dav On
<LimitExcept GET HEAD OPTIONS PUT>
Allow from all
</LimitExcept>
</Location>

That's not working. It shows error at program output: (405) The method not allowed.

1 Answer 1

4
  1. Your <Dav On directive is not complete (no need for <) -- I assume it's just a copy-paste issue.

  2. More importantly -- you are using <Location> directive ... but providing physical path on your file system/hard drive.

    That's wrong -- <Location> is used to match URLs, not directories; to match directories you need to use <Directory>. Please refer to Apache manual: http://httpd.apache.org/docs/current/mod/core.html#location

    You most likely need to use <Location /output> instead (or use <Directory> instead of <Location>) -- that's my guess based on the amount of config data you have provided.

Taking the above into consideration you will need something like this (sorry, I cannot connect to my Apache box to test it):

<Location /output>
    Dav On
    <LimitExcept GET HEAD OPTIONS PUT>
        Allow from all
    </LimitExcept>
</Location>
2
  • I had some similar issues as the default config listed in the "extra/httpd-dav" file has the <Directory> syntax pre-populated, and I kept receiving 405 errors in the access.log. Since reading this post, I have changed it to <Location> and everything worked like a charm. Thanks for the tip!
    – user38020
    Commented Apr 22, 2014 at 1:00
  • Don't you mean Limit rather than LimitExcept? Otherwise you have not allowed any access for PUT. Commented Oct 18, 2022 at 4:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.