【发布时间】:2018-06-14 13:02:35
【问题描述】:
我在搜索中看到过这样的问题,但我仍然无法弄清楚。 我可以在本地主机上运行我的 WCF 并在一个简单的 html 中调用这些方法,所以我知道它可以工作。
这是网络配置:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6.1"/>
<pages validateRequest="false" />
<httpRuntime targetFramework="4.6.1"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors >
<behavior name="ServiceBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="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>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="WCFBolig.Service1" behaviorConfiguration="ServiceBehavior">
<endpoint binding="webHttpBinding"
contract="WCFBolig.IService1"
behaviorConfiguration="web"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment 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>
<connectionStrings>
<add
name="DatabaseConnection"
connectionString="server=XX;database=XX;user=XX;password=XX"
providerName="System.Data.SqlClient"
/>
</connectionStrings>
</configuration>
我不确定是否需要“mex”端点。
当我尝试在 IIS 上托管它时,我右键单击站点,添加网站,为其命名和端口,但我不确定物理路径。我已经尝试使用直接指向项目的路径:C:\Users\me\source\repos\WCFBolig\WCFBolig
我在尝试浏览时收到此错误:
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 0x80070005
Config Error Cannot read configuration file due to insufficient permissions
Config File \\?\C:\Users\me\source\repos\WCFBolig\WCFBolig\web.config
Requested URL http://localhost:777/
Physical Path
Logon Method Not yet determined
Logon User Not yet determined
Config Source:
-1:
0:
我尝试将文件夹移动到其他地方,看看它是否可以在那里访问它,但没有奏效。我试过查看 webconfig 文件的权限,但看不到与 IIS 有任何关系。
正确的步骤是什么? 如果我需要发布有关该项目的更多信息,请告诉我,无论如何感谢您的宝贵时间。
编辑:新错误万岁:
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 BeginRequest
Handler Not yet determined
Error Code 0x80070021
Config Error This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
Config File \\?\C:\inetpub\WCFBolig\WCFBolig\web.config
Requested URL http://localhost:7778/Service1.svc
Physical Path C:\inetpub\WCFBolig\WCFBolig\Service1.svc
Logon Method Not yet determined
Logon User Not yet determined
Config Source:
38: <system.webServer>
39: <modules runAllManagedModulesForAllRequests="true"/>
40: <!--
我从这里得到了答案:Config Error: This configuration section cannot be used at this path 他们都没有被检查,所以我检查了除了 CGI 之外的所有内容,现在得到这个错误:
HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
Most likely causes:
It is possible that a handler mapping is missing. By default, the static file handler processes all content.
The feature you are trying to use may not be installed.
The appropriate MIME map is not enabled for the Web site or application. (Warning: Do not create a MIME map for content that users should not download, such as .ASPX pages or .config files.)
If ASP.NET is not installed.
Things you can try:
In system.webServer/handlers:
Ensure that the expected handler for the current page is mapped.
Pay extra attention to preconditions (for example, runtimeVersion, pipelineMode, bitness) and compare them to the settings for your application pool.
Pay extra attention to typographical errors in the expected handler line.
Please verify that the feature you are trying to use is installed.
Verify that the MIME map is enabled or add the MIME map for the Web site using the command-line tool appcmd.exe.
To set a MIME type, use the following syntax: %SystemRoot%\windows\system32\inetsrv\appcmd set config /section:staticContent /+[fileExtension='string',mimeType='string']
The variable fileExtension string is the file name extension and the variable mimeType string is the file type description.
For example, to add a MIME map for a file which has the extension ".xyz": appcmd set config /section:staticContent /+[fileExtension='.xyz',mimeType='text/plain']
Warning: Ensure that this MIME mapping is needed for your Web server before adding it to the list. Configuration files such as .CONFIG or dynamic scripting pages such as .ASP or .ASPX, should not be downloaded directly and should always be processed through a handler. Other files such as database files or those used to store configuration, like .XML or .MDF, are sometimes used to store configuration information. Determine if clients can download these file types before enabling them.
Install ASP.NET.
Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click here.
Detailed Error Information:
Module StaticFileModule
Notification ExecuteRequestHandler
Handler StaticFile
Error Code 0x80070032
Requested URL http://localhost:7778/Service1.svc
Physical Path C:\inetpub\WCFBolig\WCFBolig\Service1.svc
Logon Method Anonymous
Logon User Anonymous
【问题讨论】:
-
嗯,它是一个权限问题,IIS用户不能访问你的个人目录,所以你做必须把服务放在一个可以访问的目录。如果这导致一个新的错误,那么研究那个错误。
-
哦,我已将其移至默认网站的文件所在的位置,您是对的,我确实收到了一条新的错误消息。谢谢,我会做更多的研究。
-
您是否在 Windows Features .NET Framework 中为 HTTP 激活了 WCF?
-
你写的 当我尝试在 IIS 上托管它时,我右键单击站点,添加网站,给它一个名称和一个端口这是错误的,你需要创建
Application不是website