我们已经在Visual Studio 2013中使用.Net 4.5创建了一个Web服务。这个webservice在同一台计算机上运行良好。
现在我们要将此Web服务导出到带有IIS的Windows Server 2008。我们已经在端口8080上运行了一个web服务。
但是当我们将导出的文件复制到此网络服务器的根目录时,发生了以下错误:
Error Summary
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Detailed Error Information
Module
IIS Web Core
Notification
Unknown
Handler
Not yet determined
Error Code
0x80070032
Config Error
The configuration section 'system.serviceModel' cannot be read because it is missing a section declaration
Config File
\\?\C:\inetpub\wwwroot\YOR24Websevices\web.config
Requested URL
http://localhost:8080/
Physical Path
Logon Method
Not yet determined
Logon User
Not yet determined
Config Source 10: </system.web>
11: <system.serviceModel>
12: <bindings>
我们在Visual Studio中导出的webconfig是:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="RightNowSyncBinding">
<security defaultAlgorithmSuite="Default" authenticationMode="UserNameOverTransport"
requireDerivedKeys="true" securityHeaderLayout="Lax" includeTimestamp="false">
<localClientSettings detectReplays="false" />
<localServiceSettings detectReplays="false" />
</security>
<textMessageEncoding messageVersion="Soap12" />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://tkbc-fleetsupport--tst.custhelp.com/cgi-bin/tkbc-fleetsupport--tst.cfg/services/soap"
binding="customBinding" bindingConfiguration="RightNowSyncBinding"
contract="RightNowServiceReference.RightNowSyncPort" name="RightNowSyncPort" />
</client>
<behaviors>
<serviceBehaviors>
<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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Yor24Service.Service">
<endpoint address="" contract="Yor24Service.IService" binding="basicHttpBinding"/>
<endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding"/>
</service>
</services>
<protocolMapping>
<add binding="basicHttpBinding" scheme="http" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
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.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
这个生成的配置文件有什么问题?
答案 0 :(得分:9)
从.Net Framework 4服务行为开始,不需要名称(MSDN)。在.Net 4之前,它是强制性的。因为您的服务行为没有名称:
<serviceBehaviors>
<behavior>
<!-- name attribute missing in behavior -->
</behavior>
</serviceBehaviors>
并且IIS发出错误我怀疑你的应用程序池没有运行.Net 4或更新。
答案 1 :(得分:0)
尝试此链接,解决方案3与我合作
Solution 3: Run attached javascript file
The above solutions do not fix the Issue 3. So I created a javascript FixServiceModel30Reg.js to fix the problem. You can run it as following to fix all of the above issues. Steps:
· Download the script FixServiceModel30Reg.txt and save it to the root of c: drive.
· Rename it to FixServiceModel30Reg.js.
· Open the Command Prompt window and run the following command:
Cscript.exe c:\FixServiceModel30Reg.js