Kyle Gobel
Kyle Gobel

Reputation: 5750

Servicestack Razor, setting Layout to Null

Using ServiceStack.Razor and having a slight issue.

I have a default _Layout.cshtml page that is my base layout, but for some pages, I don't want a layout, I just want to a full html page with no templating, similar to how setting the Layout to null in ASP.NET MVC would work.

I cannot figure out how to do this, and can't find anything in the documentation (not saying it's not there, just can't find it).

Things I've tried:

  1. Setting the Layout property to null on the actual view page:

    @{ Layout = null; }

  2. Returning a null template from the actual service:

    return HttpResult(dto) { Template = null; };

  3. Moving my view page out of the Views folder (this just took it back to the default ServiceStack view page)

Any help greatly appreciated.

Thanks, and sorry if I missed something simple

Upvotes: 2

Views: 287

Answers (1)

mythz
mythz

Reputation: 143389

Layout=null indicates no Layout was specified, so will use the default _Layout.cshtml.

You can use an empty string "" for no Layout, e.g:

@{
    Layout = "";
}

Otherwise if preferred, create an "Empty" layout e.g: /Views/Shared/Empty.cshtml containing just:

@RenderBody()

Upvotes: 1

Related Questions