سؤال

When I copied my Websites using .svc-ASP.Net 4 Services from Windows Server 2008 to Windows Server 2012, I get a 405 Response for every .svc-Request being triggered by a Silverlight application.

In Windows Server 2008 everything worked perfectly.

I tried aspnet_regiis and the WCF Register (ServiceModelReg). The file .svc is also included into the Module Mappings in IIS 8. I also uninstalled ASP.NET 4.5+3.5 and reinstalled it and the WCF HTTP Hosting.

All Websites are affected by this migration.

Request:

POST /Data/search.svc HTTP/1.1
Accept  */*

Response:

HTTP/1.1 405 Method Not Allowed
Allow:  GET, HEAD, OPTIONS, TRACE

The files look the following way, I also tried to add 'WebInvoke'.

[ServiceContract]
public interface IPackages
{
    /// <summary>
    /// Gets a package by a public key
    /// </summary>
    /// <param name="publicKey">Used public key</param>
    /// <returns>Information about the package</returns>
    [OperationContract]
    PackageInformation GetPackageByPublicKey(string publicKey);

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Packages" in code, svc and config file together.
public class Packages : IPackages
{
    /// <summary>
    /// Gets a package by a public key
    /// </summary>
    /// <param name="publicKey">Used public key</param>
    /// <returns>Information about the package</returns>
    public PackageInformation GetPackageByPublicKey(string publicKey)
    {
            return packageManager.GetPackageByPublicKey(publicKey);
    }
}

Thanks for any hint.

هل كانت مفيدة؟

المحلول

On Windows 2012 you need to go to Server manager, then Add Roles and Features. Click next a couple of times till you get to the Server Roles options. From there, expand Application Server and select "Web Server (IIS) Support". Next you need to select Http Activiation and maybe TCP Activation (I did both), this is what enables support for WCF on 2012.

It should select all necessary dependencies for you, but it might be that you also need to go to the "Web Server (IIS)" section, then "Application Development" and select the ASP.NET option that you need (I had already installed these options first, so I don't know if it's necessary to do this or not if only doing the Support option). This will create the .svc handler for you.

نصائح أخرى

I had to create a new managed handler for *.svc with following type:

 System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

Quite strange that this is not done by Default.

To clarify and expand upon the accepted answer with a view to being helpful in the future (it helped me a lot, I hate working with SilverLight in a legacy app)...

  1. On Windows 2012 you go to Server manager, then click Add Roles and Features.

  2. Click next a couple of times till you get to the Server Roles options.

  3. From there, check Application Server and click next twice.

  4. Select "Web Server (IIS) Support", and a popup window will appear listing the features, click the Add Features button, then click the next button and then click the install button.

  5. "Next you need to select Http Activiation and maybe TCP Activation (I did both), this is what enables support for WCF on 2012."

  6. To do this go back to the Server Manager and click Add Roles and Features.

  7. Click next a couple of times till you get to the Server Roles options, then in the left panel click the Features entry.

  8. Then expand .Net 4.5, then expand WCF Services, then select HTTP Activation (other types are available at this point, add them as necessary), and continue to install it.

These steps resolved the 405 issue for me.

I only needed HTTP Activation.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top