C# 公开wcf服务元数据
我正在学习关于设置wcf服务的教程。我完成了它所说的更改,直到它第一次说要启动服务为止。在web浏览器中导航到端点时,我会收到404或403.14错误。最初,该服务显示文件夹结构,但我删除了启用该结构的web.config文件中的属性。我确定问题与该文件有关,但我不确定还需要更改什么。 指南链接: Web.config文件:C# 公开wcf服务元数据,c#,web-services,wcf,web-config,C#,Web Services,Wcf,Web Config,我正在学习关于设置wcf服务的教程。我完成了它所说的更改,直到它第一次说要启动服务为止。在web浏览器中导航到端点时,我会收到404或403.14错误。最初,该服务显示文件夹结构,但我删除了启用该结构的web.config文件中的属性。我确定问题与该文件有关,但我不确定还需要更改什么。 指南链接: Web.config文件: <?xml version="1.0"?> <configuration> <appSettings> <add k
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
</httpModules>
</system.web>
<system.serviceModel>
<services>
<service name="WcfCalculator.Calculator" behaviorConfiguration="Metadata">
<endpoint address="" contract="WcfCalculator.ICalculator" binding="basicHttpBinding"/>
<endpoint name="mex" address="mex" contract="IMetadataExchange" binding="mexHttpBinding"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Metadata">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="ApplicationInsightsWebTracking"/>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
preCondition="managedHandler"/>
</modules>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>
我认为403.14可能与您的文件夹权限有关。您的应用程序池在哪个帐户下运行以及.NET Framework的版本?确保您的应用程序池以Framework 4.0为目标。403.14-很可能您正在尝试浏览根目录,并且IIS中禁用了目录浏览功能,或者您的应用程序池没有足够的权限。然后,尝试删除protocolMapping
在VS2015中,您可以将.svc文件设置为启动文档。点击“F5”将在WCF测试客户端(WcfTestClient.exe)中打开该文档。或者,您可以右键单击.svc文件并选择“在浏览器中查看”。我认为403.14可能与您的文件夹权限有关。您的应用程序池在哪个帐户下运行以及.NET Framework的版本?确保您的应用程序池以Framework 4.0为目标。403.14-很可能您正在尝试浏览根目录,并且IIS中禁用了目录浏览功能,或者您的应用程序池没有足够的权限。然后,尝试删除protocolMapping
在VS2015中,您可以将.svc文件设置为启动文档。点击“F5”将在WCF测试客户端(WcfTestClient.exe)中打开该文档。或者,您可以右键单击.svc文件并选择“在浏览器中查看”。您所说的“什么帐户”是什么意思?它的目标是.net版本4.5.2。我假设它试图浏览文件夹,我关闭了文件夹浏览,但是我应该打开什么才能进入这个屏幕?我现在只是通过VisualStudio托管服务。它还没有在IIS上。好的,你使用的是卡西尼号,不是IIS。您说您看到了文件夹结构,然后禁用了它-如果您不将服务设置为启动文档,将导致403错误。您还可以右键单击svc文件并在浏览器中查看它。再说一次,我不知道为什么会有协议映射。我会使用您正在关注的示例中提供的配置文件,然后添加任何您需要的内容,例如app insights和SSL。将有关右键单击.svc文件的信息添加到答案中,我将接受它。您所说的“什么帐户”是什么意思?它的目标是.net版本4.5.2。我假设它试图浏览文件夹,我关闭了文件夹浏览,但是我应该打开什么才能进入这个屏幕?我现在只是通过VisualStudio托管服务。它还没有在IIS上。好的,你使用的是卡西尼号,不是IIS。您说您看到了文件夹结构,然后禁用了它-如果您不将服务设置为启动文档,将导致403错误。您还可以右键单击svc文件并在浏览器中查看它。再说一次,我不知道为什么会有协议映射。我将使用您正在关注的示例中提供的配置文件,然后添加您需要的任何内容,如app insights和SSL。将有关右键单击.svc文件的信息添加到答案中,我将接受它。
using System.ServiceModel;
namespace WcfCalculator
{
[ServiceContract]
public interface ICalculator
{
[OperationContract]
double AddNumbers(double number1, double number2);
[OperationContract]
double SubstractNumbers(double number1, double number2);
[OperationContract]
double MultiplyNumbers(double number1, double number2);
[OperationContract]
double DivisionNumbers(double number1, double number2);
}
}