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