Additional fallback for SPA #321
-
Hello, E.g. if I have a page Now the problem is when I start using resource id parameter inside the path, e.g. addressing the resource as I was trying several ways to achieve this with the current state of things, but I couldn't get it to work. This is my initial setup: var httpContent = Layout
.Create()
.Add("api", api)
.Fallback(SinglePageApplication.From(ResourceTree.FromDirectory("www")))
; What I would like to have is if the SPA does not find a matching resource, instead of rendering 404, I want it to return "index.html". E.g. something like this: var httpContent = Layout
.Create()
.Add("api", api)
.Fallback(SinglePageApplication.From(ResourceTree.FromDirectory("www")).Fallback(Resource.FromFile("www\\index.html")))
; |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Just for clarification - if We could add a general
Maybe |
Beta Was this translation helpful? Give feedback.
Just for clarification - if
/accounts/123456
ist requested - would you expect aHTTP 200
with the content of yourindex.html
? Or a HTTP redirect to your app root? I think returningHTTP 200
will cause some irritation for clients (such as search engines).We could add a general
Fallback
concern which will evaluate the inner handler and if it does not return anything return the specified content instead. This would allow to.Fallback()
on any handler, and also to specify multiple fallbacks if needed. In your case this then could be: