piranah-cms in ASP.NET MVC: Not able to preview - asp.net-mvc

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:
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

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

Related

Implementing ASP.NET web with WIF & ADFS 1.0

I have developed a solution with ASP.NET front-end using WCF-services as back-end. The web-site currently authenticates using ADFS 1.0 (I do not have any control of the ADFS-implementation but it has been configured for my web-application). Also, it's no option to upgrade to ADFS 2.0 (at least not in the near future)
The configuration in Web.config for this is the following:
<httpModules>
<add name="Identity Federation Services Application Authentication Module" type="System.Web.Security.SingleSignOn.WebSsoAuthenticationModule, System.Web.Security.SingleSignOn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null" />
</httpModules>
<membership defaultProvider="SingleSignOnMembershipProvider2">
<providers>
<add name="SingleSignOnMembershipProvider2" type="System.Web.Security.SingleSignOn.SingleSignOnMembershipProvider2, System.Web.Security.SingleSignOn.PartialTrust, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fs="https://urltoadfs/adfs/fs/FederationServerService.asmx" />
</providers>
</membership>
<websso>
<authenticationrequired />
<urls>
<returnurl>https://myapplication/</returnurl>
</urls>
<fs>https://urltoadfs/adfs/fs/FederationServerService.asmx</fs>
<isSharePoint />
</websso>
This works fine and i can access the application using an account in ADFS. The problem is that I need to convert this claim-identity to a WindowsIdentity to access the back-end WCF services (they use Windows Authentication with impersonation/delegation).
Is there any way to accomplish this with ADFS 1.0? I have tried to use WIF (Windows Identity Foundation) but I cannot find any clear information if it's possible to use it together with ADFS 1.0 as STS. I have also investigated the "Windows NT token-based applications"-option (http://technet.microsoft.com/en-us/library/cc784956(v=ws.10).aspx) but I would like to avoid changes in the current ADFS-implementation if possible.
To test the WIF-option I used the following configuration in Web.config (the part on websso removed):
<httpModules>
<add name="SessionAuthenticationModule" type="Microsoft.IdentityModel.Web.SessionAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="WSFederationAuthenticationModule" type="Microsoft.IdentityModel.Web.WSFederationAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="ClaimsAuthorizationModule" type="Microsoft.IdentityModel.Web.ClaimsAuthorizationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</httpModules>
<microsoft.identityModel>
<service>
<audienceUris>
<add value="https://myapplication/" />
</audienceUris>
<applicationService>
<claimTypeRequired>
<claimType type="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn" optional="true" />
</claimTypeRequired>
</applicationService>
<securityTokenHandlers>
<add type="Microsoft.IdentityModel.Tokens.Saml11.Saml11SecurityTokenHandler, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<samlSecurityTokenRequirement mapToWindows="true" useWindowsTokenService="true" />
</add>
</securityTokenHandlers>
<federatedAuthentication>
<wsFederation passiveRedirectEnabled="true"
issuer="https://urltoadfs/adfs/fs/FederationServerService.asmx"
realm="https://myapplication/"
requireHttps="true" />
</federatedAuthentication>
</service>
</microsoft.identityModel>
I also have the "Claims to Windows Token Service" (c2WTS) running on the web-server.
I get redirected to the ADFS-server but I just receives a general error from the server.

How to share web.config file between MVC 3 and MVC 4 Project

I have a MVC 3.0 and MVC 4.0 Projects side by side
I did this for the resource sharing between two solutions. it is works fine when i change the config file. changes in details.
In MVC 3.
<assemblies>
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages"/>
</namespaces>
</pages>
When i remove the <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> MVC 4 is working fine. after i debug the project in MVC 3.0 it showing an error msg(The type or namespace name 'Ajax' does not exist in the namespace 'System.Web.Mvc' (are you missing an assembly reference?)
) because of i remove the "System.Web.Mvc, Version=3.0.0.0" , if i have to run that means i have to place the refreance again. here i am doing everyting manually, is there is any way to automatic do this ?
For example, two xml files in server side i read that xml file and replace the config file.
Already Tried.
In MVC 4 project i used the WebConfigurationManager to remove the refreance it works , after i opened the MVC 3 it shows that error msg.
You could create a new build configuration for Mvc3 and run a pre-build event that will overwrite your web.config, it's an idea I've adopted from Hanselman.
If you follow the link the only difference for your set up would be that you would have a config called
Web.Config.Mvc3 (and possibly Web.Config.Mvc3Release)
and leave Mvc as your default builds
Web.Config.Debug
Web.Config.Release

Razor Compiler Warning/Errors - ASP.NET MVC 4

I have an issue which seems to have been reported here:
Need razor view engine auto-complete to work in a class library?
My issue is the following Warning:
G:\Accountable\Accountable\Views\LedgerUser\EditorTemplates\LedgerServiceViewModel.cshtml:
ASP.NET runtime error: There is no build provider registered for the
extension '.cshtml'. You can register one in the
section in machine.config or web.config.
Make sure is has a BuildProviderAppliesToAttribute attribute which
includes the value 'Web' or 'All'.
This issue is apparent in all my views. Sample images below.
Now all posts and references online that I have found are referencing to adding various Web.config (as mentioned in the previous post) options, but this doesn't seem to work, as I have these configurations defaulted in the project. Here are my Web Configs:
Main Web.config
View root Web Config
I think this issue maybe while im also getting the following compiler errors on the Views:
The name 'Html' does not exist in the current context
What am I doing wrong?
Arrrgghhh i had missed the following from the ROOT Web.config:
<compilation debug="true" targetFramework="4.0">
<!-- New -->
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
This allowed fixed the error and allowed me to use Intellisense within the View.
Putting back the following lines in root Web.config fixed:
<system.web>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<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="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
I got it working by simply unloading and reloading the project. All the namespaces above were already there in the root web.config and I was still getting this issue.
Removing the temporary asp.net framework files works for me.
Stop IIS and remove everything under this folder:
C:\Windows\Microsoft.NET\Framework64\[framework version]\Temporary ASP.NET Files
Then restart IIS. Bam!
I tried by restart IIS, removed Temporary ASP.NET Files and changing the compilation tag in the web config file. None of them work for me.
I fixed the issue by removing and adding System.Web.MVC to the project.
In my case Razor syntax are Highlighted in red.

ms reportviewer not show data on host server

I have created an Asp.net Project, I use MS Reportviewer for Reports of my project. When I place this project in my IIS by creating new Application in my main project. In it my reports Shows Correct but when I place this project on shared host by creating Virtual directory under my main project then No Data shows in it and the following error comes.
**Not Found**
The requested document was not found on this server.
In my webpage I call Report as Shown below
<div>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
Font-Size="8pt" Height="575px" Width="100%">
<localreport reportpath="Reports\rptChartofAccount.rdlc">
<datasources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="trialBalnace_vwBalanceSheet" />
</datasources>
</localreport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetData" TypeName="AmsWeb.trialBalnaceTableAdapters.vwBalanceSheetTableAdapter" >
</asp:ObjectDataSource>
</div>
and in my Code Behind
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ObjectDataSource1.SelectParameters.Add("brid", Session("BrId"))
Dim Param(0) As ReportParameter
Param(0) =New ReportParameter("BrName", Session("BrName").ToString)
ReportViewer1.LocalReport.SetParameters(Param)
ReportViewer1.LocalReport.Refresh()
End Sub
for ms reportviewer web.config file is as follows
<httpHandlers>
<remove path="*.asmx" verb="*"/>
----------
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>
</httpHandlers>
<httpModules>
and Assembly added as following
<assemblies>
<clear/>
<add assembly="*"/>
<add assembly="Microsoft.ReportViewer.WinForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</assemblies>
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</buildProviders>

Do not see the controller and model

in views/jump/index have problem.
first rows:
#model IEnumerable<WhislaMvc.Areas.Admin.Models.Jump>
#{
ViewBag.Title = "Index";
}
#model and ViewBaf - do not see.
I take error:
compilation Error Compiler Error Message: CS0103: The name 'model'
does not exist in the current context Compiler Error Message: CS0103:
The name 'ViewBug' does not exist in the current context
Update:
I comment model and ViewBag
#Html.ActionLink("Create New", "Create")
Html not have method ActionLink why????
From your question description, it shows that, I think you are using Asp.Net MVC 2 and you just tried to use the functionality of Asp.Net MVC 3.
ViewBag comes with Asp.Net MVC 3 (It's feature of Asp.Mvc 3)
There are few suggestions that you can try to avoid compilation error.
Install Asp.Net MVC 3 (Install .Net Framework 4 prior)
Change your project property. (Right Click Web Project -> click
'Properties' -> Application tab -> Target Framework -> Change to
.NET Framework 4
Check and Change your web.config as below:
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
Hope this helps!
All the problems were with the configuration of Web.Config in Area / Admin / Views
WebConfig I get from Views/Web.Config/ is standart.

Resources