2009-10-24 117 views
0

我創建並部署了一個非常簡單的WCF服務。但是從IE瀏覽器訪問時,我得到這個:HTTP錯誤500.19內部服務器錯誤

 
HTTP Error 500.19 - Internal Server Error 
Description: The requested page cannot be accessed because the related configuration 
data for the page is invalid. 

Error Code: 0x80070005 

Notification: BeginRequest 

Module: IIS Web Core 

Requested URL: http://localhost:80/ProductsService/ProductsService.svc 

Physical Path: C:\Users\Administrator\Documents\Visual Studio 2008\Projects\ProductsService\ProductsService\ProductsService.svc 

Logon User: Not yet determined 

Logon Method: Not yet determined 

Handler: Not yet determined 

Config Error: Cannot read configuration file 

Config File: \\?\C:\Users\Administrator\Documents\Visual Studio 2008\Projects \ProductsService\ProductsService\web.config 

Config Source: -1: 
        0: 
More Information... This error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the event logs may contain more information about what caused this error. 

這裏是我的web.config文件的內容:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <configSections> 
     <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> 
    </configSections> 
    <dataConfiguration defaultDatabase="AdventureWorksConnection" /> 
    <connectionStrings> 
     <add name="AdventureWorksConnection" connectionString="Database=AdventureWorks; Server=(localhost)\SQLEXPRESS;Integrated Security=SSPI" 
      providerName="System.Data.SqlClient" /> 
    </connectionStrings> 

    <system.serviceModel> 
    <services> 
     <service name="Products.ProductsService"> 
     <endpoint address="" 
     binding="basicHttpBinding" 
     contract="Products.IProductsService" /> 
     </service> 
    </services> 
    </system.serviceModel> 

</configuration> 
+0

我相信你的IIS並不知道.svc文件 - 請參閱此博客文章,瞭解更多信息和解釋如何解決該問題:rogerpence.com/blog/?p=280 – 2009-10-24 20:14:31

+0

看看我的答案http://stackoverflow.com/questions/5091640/http-error-500-19-internal-server-error/29032247#29032247。希望這有助於... – 2015-03-13 13:22:23

回答

2

嗯,它看起來像你的服務不公開任何元數據交換根本不需要 - 至少需要添加serviceMetadata行爲,以便客戶端可以查詢服務的元數據,並且如果您希望能夠使用瀏覽器檢索該元數據,則還需要在該服務元數據上啓用httpGet行爲:。

擴展你的web.config這樣的:

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="Metadata"> 
      <serviceMetadata httpGetEnabled="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service name="Products.ProductsService" behaviorConfiguration="Metadata"> 
     <endpoint address="" 
     binding="basicHttpBinding" 
     contract="Products.IProductsService" /> 
     </service> 
    </services> 
    </system.serviceModel> 

馬克

+0

我認爲這是安全相關的,因爲我給我的服務文件夾的用戶訪問IIS_USRS,現在,我得到另一個錯誤: HTTP錯誤404.3 - 找不到 說明:您請求無法在這個網頁由於在Web服務器上配置了多用途Internet郵件擴展(MIME)映射策略而被提供服務。您請求的頁面具有不被識別的文件擴展名,並且不被允許。 – Attilah 2009-10-24 15:14:18

+2

我相信你的IIS並不知道有關.svc文件 - 請參閱此博客文章以獲取更多信息和解釋如何解決該問題:http://rogerpence.com/blog/?p=280 – 2009-10-24 16:25:01

0

爲404.3錯誤你有沒有采取看看這個link

希望這會有所幫助。

+0

沒有提到403錯誤 – msulis 2010-03-08 04:53:43

+0

抱歉,我的意思是404.3 ..一定是一個錯字錯誤..我會編輯我的文章。謝謝。 – daxsorbito 2010-03-09 05:43:51

1

檢查Web應用程序文件夾權限並確保包含以下用戶和組的完整權限:\ IIS_IUSRS和\ IUSR。

相關問題