Child pages
  • How to get a vanilla N2 project to work in VS2013
Skip to end of metadata
Go to start of metadata

Start VS2013 and create a new project. Select ASP.NET Web Application. Click OK and select Empty template and select to add core references for MVC. Now right click on references and select Manage NuGet Packages. Mark Online and search for n2cms. Install N2CMS and Dinamico Templates for N2 CMS 

Go to Server explorer and right click on data connections and select Create new SQL Server Database. Enter (localdb)\v11.0 for the server name and n2 for the database. Right click on the new database in Server Explorer and select Browse in SQL Server Object Explorer. Right click on the database and select Properties. Copy the contents of Data File. In my case it was “C:\Users\Fredrik\n2.mdf”. 

Now edit web.config and create a connectionString like: 
<add name="N2CMS" connectionString="Data Source=(localdb)\v11.0; ;AttachDbFilename=C:\Users\Fredrik\n2.mdf;Initial Catalog=n2;Integrated Security=True;" providerName="System.Data.SqlClient" /> 

Alternatively you could move the database file to your project App_Data folder and reference it through: “|DataDirectory|\n2.mdf” 

Right click on the connection to your database in Server Explorer and select Close Connection. 

Run your project by hitting F5. Fix the problem with dual <validation> nodes in web.config caused by the n2 installation. 

Go through the n2 installation wizard, set your password, create database tables, import content package, and on step 3 click on the link to the management UI and your faced with this nasty error: 
[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection 

To fix the problem you need to add this to <runtime><assemblyBinding> in web.config 
<dependentAssembly> 
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
</dependentAssembly>