【问题标题】:piranah-cms in ASP.NET MVC: Not able to previewASP.NET MVC 中的 piranha-cms:无法预览
【发布时间】:2014-05-31 10:13:17
【问题描述】:

我正在尝试将 PiranahCMS 设置到我的 MVC 应用程序中。我能够创建数据库并访问管理员(管理器部分),其中可以创建页面等,如下所示:

一旦我尝试发布页面,我就会收到以下错误:

“/”应用程序中的服务器错误。


[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection. Type A originates from 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'. Type B originates from 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Users\harry\AppData\Local\Temp\Temporary ASP.NET Files\root\791319c4\b6685f9c\assembly\dl3\bdf36010\0d3a5a0e_b07ccf01\System.Web.WebPages.Razor.dll'.
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.InvalidCastException: [A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection. Type A originates from 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'. Type B originates from 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Users\harry\AppData\Local\Temp\Temporary ASP.NET Files\root\791319c4\b6685f9c\assembly\dl3\bdf36010\0d3a5a0e_b07ccf01\System.Web.WebPages.Razor.dll'.

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.

我正在使用 Visual Studio 2013、MVC 4 和 .NET 4.5。 Web.config 如下:

已经用passiveMove="true"测试过

<settings>
      <managerNamespaces value="" />
      <disableManager value="false" />
      <passiveMode value="**false**" /> <!-- Have tested with  passiveMove="true" as well -->
      <prefixlessPermalinks value="false" />
    </settings>
    <providers>
      <mediaProvider value="Piranha.IO.LocalMediaProvider, Piranha" />
      <mediaCacheProvider value="Piranha.IO.LocalMediaCacheProvider, Piranha" />
      <cacheProvider value="Piranha.Cache.WebCacheProvider, Piranha" />
      <logProvider value="Piranha.Log.LocalLogProvider, Piranha" />
    </providers>
  </piranha><system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceAuthorization serviceAuthorizationManagerType="Piranha.Web.APIKeyAuthorization, Piranha" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  </system.serviceModel><connectionStrings>
    <!--    <add name="piranha-ce" connectionString="data source=|DataDirectory|Piranha.sdf" providerName="System.Data.SqlServerCe.4.0" />
        <add name="piranha-express" connectionString="data source=.\sqlexpress;initial catalog=piranha-db;user id=user;password=pass;multipleactiveresultsets=true;" providerName="System.Data.SqlClient" />
        <add name="piranha-local" connectionString="data source=(localdb)\v11.0;initial catalog=piranha-db;integrated security=true" providerName="System.Data.SqlClient" />
        -->
    <add name="piranha" connectionString="data source=VAIO;initial catalog=piranha-db;multipleactiveresultsets=true;Integrated Security=True;"   providerName="System.Data.SqlClient"  />
    </connectionStrings></configuration>

我在这里做错了什么?

如果需要任何其他信息,请告诉我。

干杯

【问题讨论】:

    标签: asp.net-mvc piranha-cms


    【解决方案1】:

    通过查看错误消息,我猜您使用的是用于 ASP.NET MVC 5 的 Piranha CMS 版本?您安装了哪个版本的 Piranha CMS。 2.1.x 版本适用于 MVC 4,2.2.0 版本已升级到 MVC5!

    干杯

    更新

    我终于注意到你的一个 cmets 有问题。你说你安装了 PiranhaCMS 包,但这个包是为 ASP.NET WebPages 准备的。 MVC 解决方案的正确包是 PiranhaCMSMvc

    希望这能解决您的问题!

    问候

    哈坎

    【讨论】:

    • 谢谢哈坎。我今晚会检查它,看看它是否有效。我们有关于 Piranah 的视频学习资料吗?还是书?
    • Hi Håkan 1) 在 MVC 4 中,我安装了 Install-Package PiranhaCMS -Version 2.1.6 2) 签入预览时出现以下错误。 “/”应用程序中的服务器错误。 -------------------------------------------------- - - - - - - - - - - - - - - - 没有找到您要查的资源。说明:HTTP 404。您要查找的资源(或其依赖项之一)可能已被删除、名称已更改或暂时不可用。请查看以下 URL 并确保其拼写正确。请求的网址:/page/
    • 该错误消息看起来像您的网络服务器没有为无扩展 URL 执行 ASP.NET。尝试在 web.config 中将 runAllManagedModulesForAllRequests 设置为 true
    • 我可以使用 gitHub 中的空白解决方案来运行它。
    猜你喜欢
    • 2014-04-14
    • 1970-01-01
    • 2013-11-11
    • 2015-06-11
    • 2020-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多