【发布时间】:2017-08-03 17:45:34
【问题描述】:
突然出现这个问题,我无法理解。
我的 MVC 应用程序调用 WCF 服务。那时它遇到了这个异常。这是昨天的工作。我想不出任何相关的改变,尽管它一定是什么。我可以回到该应用程序以前工作的版本,但现在出现了错误。
为什么在尝试调用 WCF 服务时涉及 WebPages.Razor?如果我查看我的引用,有一个对 System.Web.WebPages.Razor 的引用,并且该位置是有效的。看起来这个 DLL 是由 Microsoft.AspNet.WebPages nuget 包管理的......为什么它搞砸了?我安装了 2.0.20710 版的软件包... web.config 中有多个地方引用 System.Web.WebPages.Razor 2.0.0.0 版。
我的应用程序今天崩溃,昨天工作。任何想法表示赞赏...
以下是其中一个 web.config 条目的示例:
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
以下是发生异常时的完整错误消息:
System.ServiceModel.ProtocolException: '内容类型 text/html;响应消息的 charset=utf-8 与绑定的内容类型不匹配 (text/xml; charset=utf-8)。如果使用自定义编码器,请确保正确实现 IsContentTypeSupported 方法。响应的前 1024 个字节是:'
<head>
<title>Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.</title>
<meta name="viewport" content="width=device-width" />
<style>
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: '.'
**************************更新******************** ************************
我还注意到,当我尝试在导致问题的 WCF Web 服务上更新服务引用时,我遇到了同样的错误。不知何故,WebPages.Razor 在更新操作期间尝试加载,但失败了。
【问题讨论】:
-
您是否尝试过清理和重建解决方案?
-
是的,清理,重建,重新启动,重新启动 Visual Studio,更新各种包,如 Microsoft.AspNet.WebPages,其他,...许多调试技术正在进行中。谢谢。