Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer 1

  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>
share|improve this answer
    
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 Apr 22 at 1:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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