【问题标题】:How to fix the Server Error(parse Error) after deploying te asp.net site部署 te asp.net 站点后如何修复服务器错误(解析错误)
【发布时间】:2019-01-06 11:41:48
【问题描述】:

我通过 FTP 从 Visual Studio 上传了我的 asp.net 应用程序,部署后它抛出运行时(解析错误)。

我看过几个帖子并尝试了很多替代方法,但没有一个有效:

上传后报错:

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 load type 'SimpleEchoBot.WebApiApplication'.

Source Error: 


Line 1:  <%@ Application CodeBehind="Global.asax.cs" 
Inherits="SimpleEchoBot.WebApiApplication" Language="C#" %>

Source File: /global.asax    Line: 1 

正如这篇文章中提到的:Parser Error Message: Could not load type 'webmarketing',我将 CodeBehind 更改为 CodeFile,但出现了一个新错误,指出 asax.cs 不存在!

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: The file '/Global.asax.cs' does not exist.

Source Error: 


Line 1:  <%@ Application CodeFile="Global.asax.cs" 
Inherits="SimpleEchoBot.WebApiApplication" Language="C#" %>

Source File: /global.asax    Line: 1 

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET 
Version:4.7.3282.0

当时我的 plesk 文件管理器是这样的:

然后我上传了 Global.asax.cs 文件,然后出现了这个错误:

如本文所示:Parser Error: Server Error in '/' Application 我更改了 Global.asax.cs 命名空间,使其与 asax 中的继承路径相同!

修改 asax.cs 中的命名空间代码:

https://imgur.com/59d4IJK.jpg

asax 中的代码:

<%@ Application CodeBehind="Global.asax.cs" Inherits="SimpleEchoBot.WebApiApplication" Language="C#" %>

但是,上面的“此程序被组策略阻止”错误仍然出现!

我将相同的应用程序部署到 Azure,同样的解析错误,顶部提到的出现了!

“/”应用程序中的服务器错误。 解析器错误 说明:解析服务此请求所需的资源时出错。请查看以下特定的解析错误详细信息并适当地修改您的源文件。

Parser Error Message: Could not load type 'SimpleEchoBot.WebApiApplication'.

来源错误:

第 1 行: Inherits="SimpleEchoBot.WebApiApplication" Language="C#" %>

源文件:/global.asax 行:1

版本信息:Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.7.3163.0

编辑:根据 jessehouwing 的要求,这里是 Bin 文件夹截图:

正如@jeesehouwing 评论所述,我尝试预编译网站并上传,但在预编译时收到一些错误:

System.AggregateException: One or more errors occurred. ---> 
System.Exception: Publish failed due to build errors. Check the error list 
for more details.
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean 
 includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, 
CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Web.Publish.PublishService.VsWebProjectPublish. 
<>c__DisplayClass40_0.<PublishAsync>b__2()
   at System.Threading.Tasks.Task`1.InnerInvoke()
    at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task 
task) atSystem.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)atMicrosoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__88.MoveNext()
 ---> (Inner Exception #0) System.Exception: Publish failed due to build errors. 
 Check the error list for more details.<---

【问题讨论】:

  • 错误和代码都是文字,不需要截图。
  • “所以我不得不使用链接” - 不正确。您已选择使用图片链接。那个选择是不正确的。请在问题中包含相关信息。文本信息应作为文本包含在内。
  • 很抱歉给您带来不便!需要的图像用代码更新
  • 可以分享一下bin文件夹内容的截图吗?您的应用程序似乎缺少关键依赖项。
  • @jessehouwing 截图更新!

标签: c# asp.net visual-studio plesk


【解决方案1】:

看起来您只能上传一个预编译的网站,并且不能在您的部署中包含 Roslyn 编译器,因为它被主机阻止了。您可以使用 Visual Studio 中的发布配置文件来配置预编译(我怀疑您需要选择“不可更新”选项)。

另见:

更多信息

您的网络主机似乎已将允许运行的可执行文件列入白名单。这是使环境更安全的强化实践。最新版本的 ASP.NET 将 C# 编译器作为部署的一部分,用于即时编译 MVC 视图和其他元素。为此,您的应用程序将csc.exe 编译器可执行文件与您的Web 应用程序一起提供。 csc.exe 尚未被提供商列入白名单,这会阻止 Global.asax.cs 的动态重新编译。

要么针对旧版本的 ASP.NET(不提供 roslyn 编译器框架),要么预编译网站,使其不再依赖 roslyn 编译器。

【讨论】:

  • @jeesehouwing 如果是这种情况,那么它至少应该在 Azure 中工作!但它的响应方式相同!
  • 在 Azure 中,您似乎没有部署代码隐藏文件,并且您似乎没有部署 bin 文件夹中的所有依赖程序集。尝试将 global.asax.cs 添加到 Azure 部署以查看错误是否更改。
  • 查看bin文件夹的内容看是否有包含SimpleEchoBot.WebApiApplication的程序集
  • 我将 code behind(gloabal.asax.cs) 文件上传到 Azure。但仍然出现相同的错误 Parser Error Message: The file '/Global.asax.cs' does not exist. 我在 bin 文件夹中看不到任何“SimpleEchoBot.WebApiApplication”
  • @jeesehouwing 你能看看我更新的帖子吗!谢谢你
猜你喜欢
  • 1970-01-01
  • 2018-11-15
  • 1970-01-01
  • 2019-04-13
  • 1970-01-01
  • 1970-01-01
  • 2012-02-14
相关资源
最近更新 更多