Servicestack Markdown NoRender Master Layout Page, Render partial content

Hi Guys,

I am dealing with the Client End for a project that I am working on and the Client is written purely in HTML5 and Javascript with some CSS3 magic. Now we are using ServiceStack and Markdown templating engine as our Web service and Content providers.

So you know that when calling a specific service the output can be any of the following

  1. JSON
  2. HTML
  3. XML
  4. CSV
  5. JSV


The above are really handy when you want to load your javascript Grid, or display content as HTML.

Now if we think about the bigger picture we have couple of things when the output is returned as HTML. First consider this from Markdown Docs

Once the appropriate view is executed it’s output is stored in the **’Body’** variable and is merged with its
static website template. The rules for finding the appropriate master website template is simple:
It’s the first **default.shtml** page it can find, looking first in its current working directory then
recursively up the directory hierarchy until it finds one.

The view is merged with the static website template by replacing all **<–@VarName–>** with variables
generated by the page (i.e. in ScopeArgs). i.e. the executed output of the View is stored in the **Body**
variable and is embedded in the static website template by replacing all **<–@Body–>** found.



That’s good that the View is processed and merged to the Master website template what what about if we don’t want that default action to happen?

Ok so this is what you can you.

Its called Bare HTML return

So for instance if you are accessing a page like localhost/yourwebservice/param (which kicks the default merge with Master them)  then you can change the URL to this


This will override the Fusion of MD template to the Master template.

Now there are some scenarios where you will want to select a custom Master template. This is common with typical web developers like me who want some more granular control on underlying technology.

Ok so lets see how this is done

If you are using  MVC Razor

Add this as your file line in your child template file.


If you are using Markdown Razor then add the following as your first line in your .md child template file

You can also your @template instead of @Layout in the above.


I hope this helps




Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.