servicestackservicestack-razor

Custom Route for ServiceStack Razor Content Pages


I have the following content page: /folder/_new.cshtml

My intention is to have the page accessible through the following url: /folder/_new

However it seems that such file name is not mapped to the url. Is there any workaround to make it happen, perhaps by assigning a custom route instead of relying on the pretty-url-by-default feature?


Solution

  • This is a pre-defined restriction for not allowing views starting with a _ prefix to be called directly, the restriction can be removed when you're registering the ServiceStack.Razor plugin with:

    var razor = new RazorFormat();
    razor.Deny.RemoveAt(0);
    Plugins.Add(razor);