This project is read-only.

ASP.NET MVC and N2 CMS (source code for example please)

Topics: Developer Forum
Sep 1, 2008 at 1:49 PM

I have been looking at n2 cms and integration with ASP.NET MVC.   I’ve downloaded the example and have that working fine, but noticed that the EDIT supplied with the example does not have source code – it comes with a compiled N2.Edit assembly.  I tried to copy in the EDIT from the full source sample but found there to be some differences, such as the InstallationManager used.

I've made an attempt to get this working, it now builds but I am getting Initializer exception ("There is a component already registered for the given key n2.languageGateway" - this is one of 4 such failures when I try to run the project)

Would it be possible to have the full source for the MVC sample posted to save a lot of time working out what the differences are?

(also, is there any further documentation on integrating these 2 elements?)

Sep 1, 2008 at 4:54 PM
Hi, what differences are you noticing. The installation manager in the example should just be the compiled representation of the source.

The initializer exception sounds like you have a two versions of the same assembly code cluttering your /bin. Have you perhaps included the /edit code in your main project and not removed n2.edit.dll?

I'd prefer not to post the full source in each example as I don't believe it's the best way to work. The documentation would read: avoid =) What are you after more specifically? There are some extensibility points that might help and we can add more if there is a need.
Sep 2, 2008 at 10:35 AM
Hi,  I had another crack at this today and got things going ... here's the story for anyone else who wants to do down this route (I did have the deuplicate reference, but also had to make a few changes here and there):

We have created a project from your ASP.NET MVC example and have things working reasonably well.  I wanted to make some changes to the EDIT pages in the CMS and noticed that the source code was not included, so swapped the EDIT folder out for the one in the full source project.

I had to do the following:

Copied EDIT folder from full source (wwwroot) into project. 

Removed reference to N2.Edit.

Add references for Castle and NHibernate (compilation errors without these).

'N2.Edit.Web.EditSiteMapProvider.GetFilters()': no suitable method found to override C:\...\Edit\Web\EditSiteMapProvider.cs – having check this file I found that it is excluded from the source EDIT project (along with EditSiteMapNode).

Excluded Properties folder from EDIT to avoid Duplicate Assembly* attributes being defined.

'N2.Edit.Install.InstallationManager' does not contain a definition for 'InsertExportFile' and no extension method 'InsertExportFile' accepting a first argument of type 'N2.Edit.Install.InstallationManager' could be found (are you missing a using directive or an assembly reference?)  C:\...\Edit\Install\Default.aspx.cs – as above, I found this class (InstallationManager') to be excluded from the source EDIT project, so excluded it from mine.

The project would now build.

When run the project would open in the browser but we got errors for edit/navigation/Tree.aspx - Could not load file or assembly 'N2.Edit' or one of its dependencies (due to <%@ Register TagPrefix="edit" Namespace="N2.Edit.Web.UI.Controls" Assembly="N2.Edit" %>) – to resolve this issue we ran a search and replace to change the Assembly=”N2.Edit” to the name of the Assembly for my project.

All seems to be working now.

I'll be in touch with any further issues marrying the CMS with ASP.NET MVC ...

Sep 2, 2008 at 6:20 PM
Good to know. Another route might be retaining the twin-project approach, i.e. having two project files. An MVC project + /n2.edit.csproj + /edit/*.*