【发布时间】:2015-10-16 16:14:11
【问题描述】:
我正在尝试使用 VS2015 在 C# 中构建一个简单的 Web 服务,以托管在 Windows Server 2012R2 上。
我已经编写了代码,并且在 Visual Studio 调试器中托管时它可以正常工作。调试器将启动 IE 并为我提供 UI 以测试我的代码中的简单方法。我可以输入摄氏温度并返回 Farentheit 温度。所以我的理解是我的代码本身正在运行。
但是,当我发布我的项目并尝试在 IE 中加载它时,我得到:
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not create type 'TestAutomation.AutomationInterface'.
Source Error:
Line 1: <%@ WebService Language="C#" CodeBehind="~/App_Code/WebService.cs" Class="TestAutomation.AutomationInterface" %>
Source File: /TestToolsAutomation/AutomationInterface.asmx Line: 1
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.81.0
我正在通过构建 -> 发布 Web 应用程序来发布我的项目。我选择“文件系统”作为我的发布方法,并在调试配置中发布到“C:\inetpub\wwwroot\MyAppName”,文件发布选项中没有复选框。当我发布时,我的 MyAppName 文件夹中有以下文件:
-AutomationInterface.asmx
-Web.config
\App_Code
WebService.cs
我在这里看到的明显问题是没有使用我的编译代码创建的 .dll 文件。我远非 IIS 专家,但这不应该在用户第一次请求页面时创建吗?
然后我重新发布并检查了文件选项中的“发布期间预编译”。当我这样做时,会创建一个 \bin 文件夹,其中包含文件“App_Code.compiled”和“App_Code.dll”文件。但是,我在浏览器中遇到了同样的错误。
因为我的代码在 VS 调试器中工作,但在 IIS 中托管时不能,我怀疑问题出在 IIS 方面,但我不能 100% 确定这一点。
当我在 IE 中请求 IIS 页面时,我在应用程序事件日志中收到一个源为“ASP.NET 4.0.3.30319.0”的事件 1310,显示“事件代码:3006 事件消息:发生解析器错误”以及显示一堆 System.Web.Compilation 函数的堆栈跟踪。
我已在 Stack Overflow 和其他网站上搜索过此错误,但建议的解决方案似乎都无法解决我的特定问题。
如果社区可以提供任何帮助,我将不胜感激。
更新:我在服务器上启用了失败的请求跟踪。看来错误发生在这里:
154. view trace
Warning
-MODULE_SET_RESPONSE_ERROR_STATUS
ModuleName
ManagedPipelineHandler
Notification
MAP_REQUEST_HANDLER
HttpStatus
500
HttpReason
Internal Server Error
HttpSubStatus
0
ErrorCode
The operation completed successfully.
(0x0)
ConfigExceptionInfo
ManagedPipelineHandler
我缺乏完全理解 IIS 试图告诉我什么的背景。任何提示将不胜感激。
【问题讨论】:
标签: asp.net web-services iis