We're using Piranha CMS with the following setting:
<prefixlessPermalinks value="true" />
However this breaks individual posts urls generated using the Permalink helper e.g.
@UI.Permalink(post.PermalinkId)
With prefixlessPermalinks set to False this would normally be the url that is generated: /home/1st-test-blog-entry
With prefixlessPermalinks set to True the url generated becomes:
/1st-test-blog-entry (the "home" has been removed as it's prefixless)
Following a prefixless url generates the following exception:
System.Web.HttpException: Cannot use a leading .. to exit above the
top directory.
Any ideas how to circumnavigate this issue?
Attempted workarounds:
I manually prefix "/post" to the permalink generated then I added the following route mapping which catches the request:
routes.MapRoute(
name: "Post",
url: "post/{permalink}",
defaults: new { controller = "Post", action = "Index", permalink = UrlParameter.Optional },
namespaces: new[] { "Maps.Portal.Controllers" }
).DataTokens["UseNamespaceFallback"] = false;
The following controller catches the request:
public ActionResult Index(string permalink)
{
var model = GetModel(permalink);
return View(model.GetView(), model);
}
But fails as the readonly SinglePostController.CurrentPermalink property isn't being populated and so causes Piranha CMS to throw an exception. It may be interesting to note that this controller fires correctly when the draft version of the post is being viewed as the CurrentPermalink is being populated by the CMS.