Embedded Content Pages

Is it possible to serve embedded cshtml content pages (not Views)? I changed the build action on one of the content pages to embedded, but when the app was deployed without the cshtml file, I got a 404.

I’ve tried setting up the Compiled Razor Views, but this didn’t work (also 404s) - I presume because this is for Views only, not content pages.

Have a look at the RazorRockstars.CompiledViews project, the Razor .cshtml pages are compiled so they don’t need to be embedded. But you’ll need to tell ServiceStack where to look for the embedded resources.

1 Like

Cheers @mythz, the URL was changing once I switched to compiled views. The content pages were at /api. With WebHostPhysicalPath = "~".MapServerPath() + "\\api". The path of the pages moved from /api/blah to /api/api/blah once compiled Razor view was enabled. I moved the pages out of the /api folder into the root and everything worked as expected.

1 Like