0

I am trying to setup PiranahCMS into my MVC application. I am able to create database and access Admin (Manager section) where one can create pages etc as below: enter image description here

Once I try to publish the page, I am getting below error:

Server Error in '/' Application.


[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.

I am using Visual Studio 2013, MVC 4 and .NET 4.5. Web.config as below:

Have tested with 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>

What wrong I am doing here?

Please let me know in-case any other information is needed.

Cheers

user2739418
  • 1,623
  • 5
  • 29
  • 51

1 Answers1

0

By looking at the error message I'm guessing you have used a version of Piranha CMS that is intended for ASP.NET MVC 5? Which version of Piranha CMS have you installed. Version 2.1.x is for MVC 4 and version 2.2.0 was upgraded to MVC5!

Cheers

UPDATE

I finally noticed something wrong in one of your comments. You say you installed the package PiranhaCMS, but this package is for ASP.NET WebPages. The correct package for an MVC solution is PiranhaCMSMvc.

Hope this solves your problems!

Regards

Håkan

Håkan Edling
  • 2,723
  • 1
  • 12
  • 15
  • Thanks Hakan. I will check it this evening and see if it works. Do we have any video learning material on Piranah? or books? – user2739418 Jun 02 '14 at 08:08
  • Hi Håkan 1) In MVC 4 I installed with Install-Package PiranhaCMS -Version 2.1.6 2) When checkin Preview I am getting following error. Server Error in '/' Application. -------------------------------------------------------------------------------- The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Requested URL: /page/ – user2739418 Jun 03 '14 at 10:59
  • That error message looks like your webserver is not executing ASP.NET for extensionless URL's. Try setting runAllManagedModulesForAllRequests to true in your web.config – Håkan Edling Jun 05 '14 at 05:10
  • I am able to run it using blank solution in gitHub. – user2739418 Jun 06 '14 at 08:02