IIS: Microsoft.Web.WebPages.OAuth调用过时的Razor包,导致应用程序崩溃

本文关键字:Razor 崩溃 应用程序 过时 Microsoft Web WebPages 调用 OAuth IIS | 更新日期: 2023-09-27 18:07:54

我最近更新了我的项目从Mvc 3到Mvc 5,我们正试图在IIS服务器上发布应用程序,以便我们可以测试它。但是我们总是有一个严重的崩溃,我不知道是什么引起的,也不知道如何纠正它。

下面是堆栈跟踪:

Server Error in '/' Application.
Could not load file or assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. 
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
 Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Source Error: 

 An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.

=== Pre-bind state information ===
LOG: DisplayName = System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///C:/inetpub/wwwroot/MyApp/
LOG: Initial PrivatePath = C:'inetpub'wwwroot'MyApp'bin
Calling assembly : System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:'inetpub'wwwroot'MyApp'web.config
LOG: Using host configuration file: C:'Windows'Microsoft.NET'Framework64'v4.0.30319'aspnet.config
LOG: Using machine configuration file from C:'Windows'Microsoft.NET'Framework64'v4.0.30319'config'machine.config.
LOG: Post-policy reference: System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: The same bind was seen before, and was failed with hr = 0x80070002.

Stack Trace: 

[FileNotFoundException: Could not load file or assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   Microsoft.Web.WebPages.OAuth.PreApplicationStartCode.Start() +0
[InvalidOperationException: The pre-application start initialization method Start on type Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +12969195
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +12968904
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +280
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +172
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151
[HttpException (0x80004005): The pre-application start initialization method Start on type Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12968244
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12807949


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

所以让我困惑的是我们不再安装打包的System.Web.Razor了。相反,我们有System.Web.Razor版本3.0.0.0。尽管如此,我已经完成了这个链接中关于如何从mvc3升级到mvc4的所有建议,并且我的所有软件包都是最新的。

我甚至试图卸载Microsoft.Web.WebPages.OAuth包,看看它是否是原因,但它比蟑螂更有抵抗力,如果没有一个不再编译的应用程序,我就无法删除它。我需要帮助解决这种情况,我唯一的下一个选择是尝试创建一个新的应用程序和重新加载所有的东西,这是有点长和繁琐。

IIS: Microsoft.Web.WebPages.OAuth调用过时的Razor包,导致应用程序崩溃

这可能是由于汇编不匹配造成的。你必须更新Views'Web。

最后不得不重新安装。

链接后面:没有ASP。. NET MVC 5 Web应用程序模板在VS 2012?我重新整合了所有的东西,重新制作了包,现在可以运行了。