i have these settings:
customhttphandlers = { {httpstatuscode.notfound, new razorhandler("/notfound")}, {httpstatuscode.unauthorized, new razorhandler("/unauthorized")}, }
when visit inside /stars
folder doesn't exist:
/stars/asdf/xyz
it first checks /stars/asdf/default.cshtml
. goes stars/default.cshtml
, loads whichever level has default
page. so, if /stars
root folder doesn't exist @ all, /notfound
loaded.
is possible ask load /notfound
when /asdf/xyz
doesn't exist?
this behaviour under root directory:
http://localhost:2000/asdf
take /notfound
. however, doesn't under folders.
tnank you.
edit ------------------------------------------------------
i noticed if go bad url /stars/asdf
/stars
doesn't have default root /default.cshtml
exists, in case, both /notfound
-> /default
loaded 1 after other?!?
my settings wrong? ss glitched?
servicestack's routing priority, follows. servicestack calls servicestackhttphandlerfactory.gethandler
handler current route.
servicestackhttphandlerfactory.gethandler
returns:
- a matching rawhttphandler, if any.
- if domain root, handler returned
getcatchallhandlerifany(...),
if any. - if route matches metadata uri, relevant handler, if any.
- the handler returned
servicestackhttphandlerfactory.gethandlerforpathinfo
if any. - notfoundhandler.
servicestackhttphandlerfactory.gethandlerforpathinfo
returns:
- if url matches valid rest route, new resthandler.
- if url matches existing file or directory, returns
- the handler returned
getcatchallhandlerifany(...),
if any. - if it's supported filetype, staticfilehandler,
- if it's not supported filetype, forbiddenhttphandler.
- the handler returned
- the handler returned
getcatchallhandlerifany(...),
if any. - null.
the catchallhandlers array contains functions evaluate url , either return handler, or null. functions in array called in sequence , first 1 doesn't return null handles route.
the code controls whether default file served part of staticfilehandler. it's called existing files , directories.
here's relevent fragement:
foreach (var defaultdoc in endpointhost.config.defaultdocuments) { var defaultfilename = path.combine(fi.fullname, defaultdoc); if (!file.exists(defaultfilename)) continue; r.redirect(request.getpathurl() + '/' + defaultdoc); return; }
as can see, if default file isn't found @ requested directory, redirects directory chain until finds default file serve. if need change behavior, can override adding catchallhander code. more details writing catchallhandler can found in answer related question, here: https://stackoverflow.com/a/17618851/149060
Comments
Post a Comment