Getting a 404 when trying to serve Markdown Content Pages with ServiceStack.net

342 Views Asked by At

I'm having a very strange issue. In our app, I have Content Pages, in Help folder in the root of the app. Within the help folder I have a bunch of Markdown files with a .md extension. These are served with the a route, for example:

http://localhost/myapp/help/calendar

the result would be that when the user navigates to that path, the calendar.md file would be picked up by SS and sent to the browser.

The problem i'm having is that path returns a SS 404 error.

If I changed calendar.md to calendar.cshtml, it works. My content is picked up by SS and sent to the browser as expected.

Why would it provide me the content with a .cshtml file, but a .md file is giving me a 404?

I'm running SS 3.9.70.

Anyone know what could be the cause? Environmental?

Snippet from AppHost

AllowFileExtensions = { "swf", "webm", "mp4" },
MarkdownBaseType = typeof(BaseHelpPage),  
MarkdownGlobalHelpers = new Dictionary<string, Type> { { "Url",typeof(UrlHelper) } },
CustomHttpHandlers =  {
    { HttpStatusCode.Unauthorized, new RazorHandler("/AccessDenied") },
    { HttpStatusCode.Forbidden, new RazorHandler("/AccessDenied") },
    { HttpStatusCode.NotFound, new RazorHandler("/NotFound") }
},
1

There are 1 best solutions below

3
Scott On

You need to add .md and .markdown file types to ServiceStack's file extensions whitelist. In your Configure method of AppHost you can specify file extensions to allow using AllowFileExtensions:

SetConfig(new EndpointHostConfig {
    AllowFileExtensions = { "md", "markdown" }
});