簡體   English   中英

IIS - 網站 - 瀏覽 - 解析錯誤消息:解析實體名稱時出錯:第 5 行位置 51

[英]IIS - Website - Browse - Parse Error Message: an error occurred while parsing entity name : line 5 position 51

  • 在 .NET 4.7 + 中創建了一個 C# Rest API;
  • API從visual studio發布;
  • API 作為 IIS 服務安裝;
  • API 作為 swagger Service 運行,可以指向 Postman 並使用它。
  • 我已經在不同的機器(Window Server 2016)上成功測試了 API
  • 在具有相同 .NET 版本的特定機器(Window Server 2016)中,它不會運行 throwing - 相同的錯誤:

在此處輸入圖片說明

  • .NET 版本

在此處輸入圖片說明

如果我然后刪除該部分(但是在另一台機器上工作正常)它仍然會為另一個實體名稱拋出相同的錯誤:第 5 行位置 51;

  • 我試圖刪除 web.config 文件中的一些實體
  • 重新安裝 IIS。
  • 也嘗試記錄事件查看器日志文件和 iis 日志文件 - 沒有運氣。

在這里更改 web 配置中的行時仍然具有相同的第 5 行位置 51 錯誤

在此處輸入圖片說明

這里是 XML Web 配置文件:

在此處輸入圖片說明


<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" 
type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<appSettings file="..\..\AppSecrets.config">
<add key="cors" value="localhost;localhost2; ;" />
<add key="connection" value="web" />
<add key="waitandretry" value="3" />
<add key="circuitbreaker" value="3" />
<add key="circuitbreakertime" value="5" />
<add key="apikey" value="xxxxxx" />
</appSettings>
<common>
<logging>
<factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, 
Common.Logging.NLog4411">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
internalLogFile="C:\inetpub\wwwroot\sms\MyAPI\logs\InnerLog.txt" 
internalLogLevel="Error" autoReload="true">
<extensions>
<add assembly="NLog.WindowsEventLog" />
</extensions>
<targets>
<target xsi:type="File" name="log" 
fileName="${basedir}\logs\${date:format=yyyy-MM-dd}.log" 
layout="${longdate} ${uppercase:${level}} ${message}" />
<target xsi:type="EventLog" name="eventlog" source="testlogging" 
log="Application" 
layout="${message}${newline}${exception:format=ToString}" />
</targets>
<rules>
<logger name="*" minlevel="Error" writeTo="log" />
<logger name="*" minLevel="Error" writeTo="eventlog" />
</rules>
</nlog>
<system.web>
<trace enabled="true" />
<compilation targetFramework="4.7.2" />
<httpRuntime targetFramework="4.6.1" />
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" 
publicKeyToken="xxxxxx" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" 
publicKeyToken="xxxxxx" />
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" 
publicKeyToken="xxxxx" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" 
publicKeyToken="xxxxx" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" 
publicKeyToken="xxxxx" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Cors" 
publicKeyToken="xxxxx" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0" />  
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" 
publicKeyToken="xxxxx" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" 
publicKeyToken="xxxxx" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http.Owin" 
publicKeyToken="xxx" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="xxxxxx" 
culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.8.1.0" newVersion="4.8.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Autofac.Integration.WebApi" 
publicKeyToken="xxxxx" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Autofac.Integration.Owin" 
publicKeyToken="xxxxx" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" 
type="
Microsoft.CodeDom.Providers.DotNetCompilerPlatform. 
CSharpCodeProvider, 
Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, 
Culture=neutral, PublicKeyToken=xxxxx" warningLevel="4" 
compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" 
type= 
"Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, 
Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, 
Culture=neutral, PublicKeyToken=xxxx" warningLevel="4" 
compilerOptions="/langversion:default /nowarn:41008 
/define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
</compilers>
</system.codedom>
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" 
type="System.Web.Handlers.TransferRequestHandler" 
preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<defaultDocument>
<files>
<add value="/swagger" />
</files>
</defaultDocument>
</system.webServer>
</configuration>

檢查您的 : AppSecrets.config 中的 & 字符,有時錯誤號指的是該文件

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM