Web服务+ IIS =错误404.3

时间:2017-12-26 19:16:16

标签: c# asp.net wcf iis

在我的机器上,我已经使用ASP.NET启用了IIS,见下图:

enter image description here

当我转到http://localhost时,默认网站正常打开。

之后,我在.NET 4.5中的Visual Studio 2017中创建了一个默认的WCF项目。

此WCF具有 ISercvice1.cs

接口
[ServiceContract]
public interface IService1
{

    [OperationContract]
    string GetData(int value);

    [OperationContract]
    CompositeType GetDataUsingDataContract(CompositeType composite);
}

[DataContract]
public class CompositeType
{
    bool boolValue = true;
    string stringValue = "Hello ";

    [DataMember]
    public bool BoolValue
    {
        get { return boolValue; }
        set { boolValue = value; }
    }

    [DataMember]
    public string StringValue
    {
        get { return stringValue; }
        set { stringValue = value; }
    }
}

默认SVC Service1.svc ,见下文:

public class Service1 : IService1
{
    public string GetData(int value)
    {
        return string.Format("You entered: {0}", value);
    }

    public CompositeType GetDataUsingDataContract(CompositeType composite)
    {
        if (composite == null)
        {
            throw new ArgumentNullException("composite");
        }
        if (composite.BoolValue)
        {
            composite.StringValue += "Suffix";
        }
        return composite;
    }
}

在IIS中我创建了一个新站点并引用了inetpub文件夹中的文件夹:

enter image description here

但是当我尝试打开链接(http://localhost:8765/Service1.svc)时,会出现错误:

HTTP错误404.3 - 未找到

由于扩展程序配置,无法提供您请求的页面。如果页面是脚本,请添加处理程序。如果要下载文件,请添加MIME映射。

我不知道我能做些什么来解决这个错误,任何人都可以帮助我吗?

由于

1 个答案:

答案 0 :(得分:0)

我相信你需要运行aspnet_regiis.exe -i命令行。

解决方案2:尝试在.NET Framework下启用以下功能。

enter image description here