0

I am trying to integrate Piranha CMS into an existing ASP.NET MVC website. I have successfully converted my web application to use .net 4.5 MVC5 (initially it was .net 4.0, MVC4). I have added the PiranhaCMS.Mvc package which transitively added PiranhaCMS.Core package.

The getting-started guide stated to set the passiveMode to true. But I would prefer to use both mine and Piranha CMS routing mechanism. Hence I set the passiveMode to false. My Web.config is as follows:

<piranha>
    <settings>
      <managerNamespaces value="" />
      <disableManager value="false" />
      <disableTypeBuilder value="false" />
      <passiveMode value="false" />
      <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>

My RouteConfig.cs contain the following:

routes.MapRoute("Default", "{controller}/{action}/{id}",
    new {controller = "Home", action = "Index", id = UrlParameter.Optional},
    new[] {"xxx.xxx.xxx.Controllers"}
    ).DataTokens["UseNamespaceFallback"] = false;

I can access the Manager console on "http://dev.test.com/manager". But when I try to access the main existing website "http://dev.test.com", I obtain a 404 error with Requested URL: /page

I have no idea what is /page. Also I tried to create a page on the Manager console with the permalink being "http://dev.test.com/home/enews". When accessing the latter, It seems being redirected and I obtain the same 404 error as above with Requested URL: /page.

Note that when I set passiveMode to true, I can access my main existing website "http://dev.test.com". I am really looking forward to integrate Piranha CMS in my existing application and hopefully obtain guidance from someone.

Ashish
  • 510
  • 3
  • 14

1 Answers1

1

When you create an application using the template project (i.e PiranhaCMSMvc) you get two basic controller templates in your project, one for displaying pages and one for displaying posts. When you simply add the Piranha.Mvc package you don't get any of the template files.

What happens when you navigate to http://dev.test.com is that the Piranha CMS routing finds the start page, then it routes it to ~/page which in the default template would be the PageController. Since this controller isn't found you get a 404 error.

The easiest way to get started is to create a new blank application using the PiranhaCMSMvc NuGet package and take a look at the controllers included. You can then copy them to your existing application.

Best regards

Håkan

Håkan Edling
  • 2,723
  • 1
  • 12
  • 15
  • Thanks for getting back Hakan. I create a blank MVC application (note that you have 3 initial pages: localhost, localhost/Home/about, localhost/Home/Contact) as you suggested and added the PiranhaCmsMvc project. When I browse the http://localhost, I obtain the main piranha page instead of previous asp mvc default page. I can no longer access the localhost/Home/about, localhost/Home/Contact page and obtain a 404 error - MODULE_SET_RESPONSE_ERROR_STATUS - __DynamicModule_Piranha.Web.ApplicationModule, Piranha, Version=2.2.5358.37284, Culture=neutral, PublicKeyToken=null_6bd47a41-148a-4809-8127-0 – Ashish Nov 12 '14 at 11:56
  • When you say that "PiranhaCMS routing finds the start page, then it routes to ~/page", do we have any ways to prevent that route to ~/page since I already have my home page that I want to be rendered when I access the application root url? And it seems that calls to ~// is no longer returning views defined in corresponding route controller/action methods, but instead the 404 error page highlighted above. However when I defined a specific routing url, let say, ~/contact-us and map it to HomeController and action Method "Contact", the link ~/contact-us work perfectly fine. – Ashish Nov 12 '14 at 12:31