Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Piranha CMS routing issue with ASP.NET MVC

I'm in the process of trying to integrate Piranha CMS (v2.2.0) with an existing ASP.NET MVC application. I can run all the original application pages, and the CMS manager pages. I can also see drafts of pages managed by the CMS, but when I try to view the live page version hosted from the CMS I get a HTTP 404 "The resource cannot be found" message.

So the following draft url works:

http://localhost:5316/draft/start

But the following live url fails:

http://localhost:5316/home/start

The original application does have a "Home" controller which I have tried renaming to "Test" in case of conflict issues. I could see the new "Test" located content, but the /home/start url still failed.

As advised, my RouteConfig code is:

routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
    namespaces: new[] { "Maps.Portal.Controllers" }
).DataTokens["UseNamespaceFallback"] = false;

And my web.config settings are:

<settings>
  <managerNamespaces value="" />
  <disableManager value="false" />
  <passiveMode value="true" />
  <prefixlessPermalinks value="false" />
</settings>

I have tried setting the prefixlessPermalinks setting to true but this didn't help.

I'm guessing that Piranha CMS isn't catching the routes for pages hosted with itself? any ideas?

like image 448
Gavin Avatar asked Mar 11 '14 03:03

Gavin


People also ask

How does ASP NET MVC routing work?

ASP.NET MVC Routing does the same thing; it shows the way to a request. Basically, routing is used for handling HTTP requests and searching matching action methods, and then executing the same. It constructs outgoing URLs that correspond to controller actions. Routing the map request with Controller's Action Method.

Where routings are defined in MVC application?

Every MVC application must configure (register) at least one route configured by the MVC framework by default. You can register a route in RouteConfig class, which is in RouteConfig. cs under App_Start folder.

What is default routing in MVC?

The Default route maps the first segment of a URL to a controller name, the second segment of a URL to a controller action, and the third segment to a parameter named id. The Default route maps this URL to the following parameters: controller = Home. action = Index.


1 Answers

By looking at your config I can see that you have followed the guidelines for setting up Piranha CMS for an existing project by setting passiveMode to true. Let me clarify a bit what this parameter does.

Passive mode is used for applications where you only want to use Piranha CMS as a backend content store and not handle any routing. This means that this parameter effectively turns off all url's to permalinks in the system to not interfere with the existing routes of the application.

If you want to mix your existing application controllers with pages solely generated by Piranha CMS you have to set passiveMode to false which will make the routing for permalinks active again.

Once this is done you will be able to access your pages with or without prefixless permalinks.

Regards

Håkan

like image 103
Håkan Edling Avatar answered Oct 19 '22 22:10

Håkan Edling