0

我们有一个 MVC 5 Web 应用程序,目前在本地 Windows 服务器上运行良好,但我们现在想将应用程序推送到 Azure。它在多台不同的开发机器上本地构建和运行良好,并且已经在服务器上运行了近 9 个月。在部署到 Azure 时,我收到带有“模型”消息的错误页面在当前上下文中不存在。

我做了一些研究,一切都指向“视图”web.config 的问题。我已经编辑如下,但无济于事,有没有其他人遇到过类似的问题?

<?xml version="1.0"?>

<configuration>
  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral,     PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>

  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc,     Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization"/>
        <add namespace="System.Web.Routing" />
        <add namespace="Zahara.Web" />
        <add namespace="Zahara.Web.Models"/>
        <add namespace="Microsoft.PowerBI.AspNet.Mvc"/>
      </namespaces>
    </pages>
  </system.web.webPages.razor>

  <appSettings>
    <add key="webpages:Version" value="3.0.0.0"/>
    <add key="webpages:Enabled" value="false" />
  </appSettings>

  <system.webServer>
    <handlers>
      <remove name="BlockViewHandler"/>
      <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
    </handlers>
  </system.webServer>
</configuration>

根据要求提供完整的错误消息

    Compilation Error

    Description: An error occurred during the compilation of a resource         required to service this request. Please review the following specific error details and modify your source code appropriately. 

    Compiler Error Message: CS0103: The name 'model' does not exist in the current context

    Source Error: 

    Line 1:  @model Zahara.Web.Models.HomePageDataViewModel
    Line 2:  @using Zahara.Data
    Line 3:  @using Zahara.Common
4

0 回答 0