HTTP错误404.0访问WCF时 - 找不到 您正在寻找已被删除的资源,有其名称更改,或者暂时不可用。
当试图从我的浏览器访问服务。这是我的配置。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<!-- Note: the service name must match the configuration name for the service implementation. -->
<service name="WcfServiceLibrary.Service1" behaviorConfiguration="MyServiceTypeBehaviors" >
<!-- Add the following endpoint. -->
<!-- Note: your service must have an http base address to add this endpoint. -->
<endpoint contract="WcfServiceLibrary.Service1" binding="basicHttpBinding" address="http://localhost/service1" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="http://localhost/service1/mex" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors" >
<!-- Add the following element to your service behavior configuration. -->
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost/service1" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
当我在Web浏览器中键入http://localhost/service1我得到了404,但如果我删除下面的app.config,只是simpley做到这一点在后面的代码
string serviceUrl = "http://localhost/service1";
Uri uri = new Uri(serviceUrl);
host = new ServiceHost(typeof(Service1), uri);
host.Open();
一切运作良好.. 。 有任何想法吗?看起来很简单。
您是否试图在IIS或自托管中托管此项? – Martin 2012-04-15 17:46:05
自己托管。我已经创建了一个Windows窗体应用程序 – stack 2012-04-15 18:16:12
它由IIS自己托管仍然主持这个权利? – stack 2012-04-15 18:30:59