Windows Server 2012中的.svc文件响应"405方法不允许"

Ull*_*lla 2 asp.net iis iis-8 windows-server-2012

当我使用.svc-ASP.Net 4服务从Windows Server 2008复制我的网站到Windows Server 2012时,我得到了一个Silverlight应用程序触发的每个.svc-Request的响应.

在Windows Server 2008中,一切都很完美.

我尝试了aspnet_regiis和WCF注册(ServiceModelReg).文件.svc也包含在IIS 8中的模块映射中.我还卸载了ASP.NET 4.5 + 3.5并重新安装它和WCF HTTP Hosting.

所有网站都受此迁移的影响.

请求:

POST /Data/search.svc HTTP/1.1
Accept  */*
Run Code Online (Sandbox Code Playgroud)

响应:

HTTP/1.1 405 Method Not Allowed
Allow:  GET, HEAD, OPTIONS, TRACE
Run Code Online (Sandbox Code Playgroud)

文件看起来如下,我也尝试添加'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);
    }
}
Run Code Online (Sandbox Code Playgroud)

谢谢你的任何提示.

Dav*_*cks 7

在Windows 2012上,您需要转到服务器管理器,然后添加角色和功能.单击下一步,直到进入"服务器角色"选项.从那里,展开Application Server并选择"Web服务器(IIS)支持".接下来你需要选择Http Activiation和TCP激活(我都做了),这就是2012年支持WCF的原因.

它应该为您选择所有必需的依赖项,但可能还需要转到"Web服务器(IIS)"部分,然后"应用程序开发"并选择所需的ASP.NET选项(我已安装)首先是这些选项,所以如果只做支持选项,我不知道是否有必要这样做.这将为您创建.svc处理程序.