Markdown Razor cascading layout

Hi, I just can’t seem to get the cascading layout working.

I am creating docs for a project and don’t want to use DTOs if at all possible.

I have the following structure as a proof of concept.

##_Layout.cshtml ##

<head>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="/api/Content/releaseNotes.css" />
<title>Release Notes</title>
</head>
 <body>
 <div class="row">
<h1>DOCUMENTATION</h1>
<div class="col-sm-11 col-sm-offset-1">
    @RenderBody()

</div>

But when I navigate to /docs/overview the markup is being rendered, but not with the Layout as defined in _Layout.cshtml

I have tried adding default.cshtml with the appropriate @Html.Partial(“overview”) but this is also not working for me.

One other issue is that the redirect to “default.cshtml” in the absence of a markdown page doesn’t work when servicestack is in a virtual directory/application. I have tried setting WebHostUrl to “http://mylocation/app/” but it still redirects to “http://mylocation/api/docs/” rather than “http://mylocation/app/api/docs”. Is there a way around this?

Note: the cascading layout templates has only been implemented in Razor.

Also the layout page for Markdown Razor doesn’t use a Razor _Layout.cshtml page (it needs to work when Razor is not enabled), it uses a static default.htm template, see the Simple Layout Example in the Markdown Razor docs, which for your example would look like:

<head>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="/api/Content/releaseNotes.css" />
<title>Release Notes</title>
</head>
 <body>
 <div class="row">
<h1>DOCUMENTATION</h1>
<div class="col-sm-11 col-sm-offset-1">
    <!--@Body-->
</div>

As Markdown Razor doesn’t support cascading layouts your pages would need to reference the layout explicitly, e.g:

@Layout docs/default.htm

I’m not sure if I understand if we’re talking about the same issue, but Config.WebHostUrl is only for changing which external absolute url, relative urls are resolved to. If you want to redirect to a different url from where ServiceStack is hosted you would use Config.DefaultRedirectPath, e.g:

SetConfig(new HostConfig {
    DefaultRedirectPath = "docs"
}

But there was an issue with DefaultRedirectPath when ServiceStack was hosted at a /custom path which should be resolved with this commit. This should now properly resolve to /api/docs/ path and load the default document.

This change is available from v4.0.53 that’s now available on MyGet.