This is a self hosted project. There is a Views\Member.cshtml file that is set to copy always as content. The following when run returns null for the razorView. I seem to be missing something here.
var razorView = razor.GetViewPage("Member"); //e.g. /Views/Member.cshtml
var html = razor.RenderToHtml(razorView, em);
Console.WriteLine(html);
Furthermore I've tried this and it returns file not found although the file is there:
var html = razor.RenderToHtml(AppDomain.CurrentDomain.BaseDirectory +
"Views\\" + "Member.cshtml", em);
Also, is there a way to have a service gateway return the rendered razor?
Member.cshtml exists: https://db.tt/xuOSAjEj31
razor: https://db.tt/qeApkAEZGH
AppHost.cs:
Plugins.Add(new RazorFormat() {
// ScanRootPath = AppDomain.CurrentDomain.BaseDirectory + "Views"
} );
I've tested this with the ServiceStack Self Host with Razor project in ServiceStackVS after changing each
.cshtmlto Copy if newer, changedAppHost.Configure()to just:Then added the
HelloViewService below:Which works as expected where
razor.GetViewPage("Hello")returns the view inViews\Hello.cshtmland it returns the generated html.The Service Gateway is used to call Services which return Typed Response DTOs, not generated html views. You can use
base.Gatewayto access the Service Gateway in Razor Views.