5

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.

Norman H
  • 2,248
  • 24
  • 27

6 Answers6

4

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>
Norman H
  • 2,248
  • 24
  • 27
3

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

Dmitrii
  • 1,247
  • 4
  • 14
  • 28
  • This also worked for me. On Windows Home Server 2011, the nuget packager server worked as is. When the exact same code was placed on shared Windows Server 2012 hosting, it failed with a 405 each time. Tracing with Fiddler showed that the WebDAVModule was rejecting the PUT request. Adding this line resolved the issue, whereas the changes in the accepted answer did not. – Richard Moss Jan 25 '16 at 17:18
2

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

Jürgen Steinblock
  • 30,746
  • 24
  • 119
  • 189
1

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" />
Norman H
  • 2,248
  • 24
  • 27
sawe
  • 1,141
  • 14
  • 24
0

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.

Ian Mercer
  • 38,490
  • 8
  • 97
  • 133
-2

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"