Question

I am getting a (405) Method Not Found error when attempting to push a package to my locally hosted Nuget Server (Nuget.Server package) hosted on IIS 7.5 on Windows 2008 R2 Enterprise.

There is a dedicated IIS site configured for the nuget server (Called Nuget) and bound to a specific port (81 for fun).

The app pool is setup to be .NET Framework 4.0 and is in Integrated Pipeline mode.

I understand that I might need to enable PUT and DELETE verbs but have no idea which handler is responsible for handling the Nuget requests.

Was it helpful?

Solution

In integrated pipeline mode, the correct handler is the svc-Integrated-4.0 handler.

I found this out by trial and error and by reading through the source code of the Nuget Server on Codeplex.

This article on how ASP.NET processes your requests is also very helpful in understanding what is taking place under the covers.

Additionally, for this answer to be the correct one, you need to ensure that the application pool is in Integrated Pipeline mode and not Classic mode.

The relevant section of your Web.config that will need to change is listed below, specifically the list of verbs that are now supported.

<system.webServer>
    <handlers>
        <remove name="svc-Integrated-4.0" />
        <add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
        <add name="svc-Integrated-4.0" path="*.svc" verb="GET,PUT,POST,DELETE,DEBUG" type="System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
</system.webServer>

OTHER TIPS

Adding <remove name="WebDAVModule" /> to system.webServer/modules worked fine for me.

I just ran into this issue. While most errors are related to some configuration changes, it is worth mentioning that this error occures if you just specify a hostname and not a url, too.

wrong:
nuget push MyPackage.1.0.nupkg -Source nuget.company.org -ApiKey ...

right:
nuget push MyPackage.1.0.nupkg -Source http://nuget.company.org -ApiKey ...

Silly mistake

WebDAV is also a problem regarding pushing packages, and as described here disable WebDAV, you can disable webdev via web.config.

Also ensure that the IIS user for your application pool has WRITE permmissions to the Packages folder within the nuget server folder structure

Lastly, make sure you have specified the api key, or add the appsettings key

<add key="requireApiKey" value="false" />

For anyone else landing here from a search engine who is getting a 405 error but is not running their own Nuget server: one other cause of 405 errors is simply an out-of-date Nuget.exe. Check the version on your nuget.exe and update it.

Afer a few tries

Handler Mappings > ExtensionlessUrl-Handler-ISAPI-4.0_64bit > Verbs > Check "All verbs"
Handler Mappings > ExtensionlessUrl-Handler-ISAPI-4.0_32bit > Verbs > Check "All verbs"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top